Guest User

Untitled

a guest
Feb 20th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. >> class Person
  2. >> def age
  3. >> self.calculate_age
  4. >> end
  5. >>
  6. ?> def calculate_age
  7. >> 'age from person'
  8. >> end
  9. >> end
  10. => nil
  11. >>
  12. ?> class Joe < Person
  13. >> def calculate_age
  14. >> 'age of Joe'
  15. >> end
  16. >> end
  17. => nil
  18. >> j = Joe.new
  19. => #<Joe:0x257a9c>
  20. >> j.age
  21. => "age of Joe"
  22. >> p = Person.new
  23. => #<Person:0x252b14>
  24. >> p.calculate_age
  25. => "age from person"
  26. >>
Add Comment
Please, Sign In to add comment