The automatic one:
class Foo
attr_accessor :name
def initialize
@name = "no name"
end
end
The custom one:
class Foo
def initialize
@name = "no name"
end
def name
@name
end
def name= value
@name = value
end
end
Print | posted @ domenica 8 gennaio 2012 00:53