First page Back Continue Last page Overview Graphics
Writing classes requires very little overhead, and getter/setter methods are one-liners
class Person
attr_accessor :name, :age, :home_town
def initialize( name, age=20, home_town=“NYC“ )
@name = name
@age = age
@home_town = home_town
end
end
And this is a powerful and quick way of modeling data structures – and is at times preferable to using complex arrays and hashes