Last active
September 27, 2019 10:51
-
-
Save irridescentrambler/b84481904b31fce8369989ca1f2dec1b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# A simple class in Ruby | |
class Human | |
def introduce | |
"Hi, I am a #{self.class.name}" | |
end | |
end | |
Human.ancestors | |
#=> [Human, Object, Kernel, BasicObject] | |
# Object is present in Human class's ancestor tree. | |
# Hence #method of Object can be used on instances of Human class | |
Human.new.method(:introduce) | |
#=> #<Method: Human#introduce> | |
# Method object for Human's instance method #introduce | |
method(:puts) | |
#=> #<Method: main.puts> | |
# Method object for #puts method. | |
[1,2,3,4].method(:length) | |
#=> #<Method: Array#length> | |
# Method object for Array's instance method #length |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment