Mega Code Archive

 
Categories / Ruby / Class
 

Ruby makes creating readable attribute easier with attr_reader

class Animal   attr_reader :color   def initialize(color)     @color = color   end end animal = Animal.new("brown") puts "The new animal is " + animal.color