Skip to content

Instantly share code, notes, and snippets.

@iseitz
Created October 27, 2017 17:28
Show Gist options
  • Save iseitz/17b224f58099017d7b97669063b40ad1 to your computer and use it in GitHub Desktop.
Save iseitz/17b224f58099017d7b97669063b40ad1 to your computer and use it in GitHub Desktop.
Ruby triks
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