A Look at Some Ruby Code, Part 1

		  1: class Person
		  2:   attr_accessor :name, :age
		  3:   def initialize(name, age)
		  4:     @name = name
		  5:     @age  = age.to_i
		  6:   end
		  7: end
		  8: 
		  9: p1 = Person.new('elmo', 4)
		 10: p2 = Person.new('zoe', 7)
		 11: 
		 12: p1.name  # -> 'elmo'
		 13: p2.age = 4
Back
Next