Hello 클래스

Hello 클래스

1 PHP[ | ]

class Hello
{

    private $name;

    function __construct($name)
    {
        $this->name = ucfirst($name);
    }

    function salute()
    {
        echo "Hello $this->name!";
    }
}

$h = new Hello("john");
$h->salute();
# Hello John!

2 Ruby[ | ]

class Hello
   
   def initialize( name )
      @name = name.capitalize
   end

   def salute
      puts "Hello #{@name}!"
   end
   
end

h = Hello.new("john")
h.salute
# Hello John!

3 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}