Ruby Accessor Methods
C#
class Foo private string name; public string Name { set { name = value; } get { return name; } } end
Ruby
class Foo def initialize(name) @name = name end #attr_reader #get only #attr_writer #set only attr_accessor :name #get set end
It's simple ヘ(^o^)ノ
0 件のコメント:
コメントを投稿