fork download
  1. class Dessert
  2. attr_accessor :name, :calories
  3. def initialize(name,calories)
  4. @name=name
  5. @calories=Float(calories)
  6. end
  7.  
  8. def healthy?
  9. calories<200
  10. end
  11.  
  12. def delicious?
  13. end
  14. end
  15. icecream=Dessert.new('ice',100)
  16. p icecream
  17. p icecream.healthy?
Success #stdin #stdout 0s 4760KB
stdin
Standard input is empty
stdout
#<Dessert:0x89b6768 @name="ice", @calories=100.0>
true