Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 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.
- 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
- Human.new.method(:introduce)
- #=> #<Method: Human#introduce>
- # Method object for Human's instance method #introduce
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement