Displaying 1 result from an estimated 1 matches for "like_apples".
2011 May 13
4
unexpected results when extending methods to class Class and class Object
...s is an object, any class created will inherit the method
extended to Object class. Also, since when we create an instance of a
class, that instance is an object, that instance will inherit the method
extended to Object class:
ruby-1.8.7-p330 :041 > class Apple
ruby-1.8.7-p330 :042?> def like_apples?
ruby-1.8.7-p330 :043?> puts ''true''
ruby-1.8.7-p330 :044?> end
ruby-1.8.7-p330 :045?> end
=> nil
ruby-1.8.7-p330 :046 > class Object
ruby-1.8.7-p330 :047?> def like_apples!
ruby-1.8.7-p330 :048?> puts ''hell yeah''
ruby-1.8.7-p...