Use attr to add two attributes : attr « Class « Ruby






Use attr to add two attributes



class Dog
  attr :bark, true
end

dog = Dog.new

dog.bark="Woof!"
puts dog.bark # => Woof!

 








Related examples in the same category

1.Check new added instance methods against Object