Created
October 27, 2017 17:28
-
-
Save iseitz/17b224f58099017d7b97669063b40ad1 to your computer and use it in GitHub Desktop.
Ruby triks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
animal = "cat" | |
class << animal | |
def speak | |
puts "miow" | |
end | |
end | |
animal.speak | |
#self is assigned to the object and then the method is found for this class of the object via Singleton (unique methods table). One to the right, one up |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment