Constructor

클래스 생성자
__construct

1 JavaScript[ | ]

function Dog(name) {
  this.name = name;
}
var myDog = new Dog("snoopy");
console.log(myDog.name);
// snoopy

2 PHP[ | ]

class Dog {
  public $name;
  public function __construct($name) {
    $this->name = $name;
  }
}
$myDog = new Dog("snoopy");
echo $myDog->name;
// snoopy

3 Python[ | ]

class Dog(object):
	def __init__(self, name):
		super(Dog, self).__init__()
		self.name = name

mydog = Dog("snoopy")
print mydog.name
# snoopy

4 Ruby[ | ]

class Dog
  def initialize(name)
    @name = name
  end
end

myDog = Dog.new("snoopy")

5 같이 보기[ | ]

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