クラスで省略しまくり
Scala
省略しまくりって語弊があるような。コンストラクタの定義も一辺にやっちゃったみたいな感じか。
scala> class Person(var name: String, var address: String) defined class Person scala> var p = new Person("John", "Tokyo") p: Person = Person@f82888 scala> p.name res4: String = John scala> p.address res5: String = Tokyo scala> p.name="Tomy" scala> p.name res6: String = Tomy
ほう。
>> class Person >> attr_accessor :name, :address >> def initialize(name,address) >> @name = name >> @address = address >> end >> end => nil >> p=Person.new('John','Tokyo') => #<Person:0x10ebb94 @address="Tokyo", @name="John"> >> p.name => "John" >> p.address => "Tokyo" >> p.name = 'Tomy' => "Tomy"