Created
June 20, 2017 04:28
-
-
Save shivabhusal/0141700460361372bd2f0ada4668c206 to your computer and use it in GitHub Desktop.
In other languages, such as Ruby, runtime looks more like a busy market. Most language constructs are still there, buzzing all around. You can even walk up to a construct and ask it questions about itself. This is called Introspection
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
class Board | |
def initialize(text) | |
@text = text | |
end | |
def display | |
@text | |
end | |
end | |
my_object = Board.new("Today is monday!") | |
# Start interactive Ruby session | |
require 'irb' | |
IRB.start | |
# introspection section | |
my_object.class # => Board | |
my_object.class.instance_methods(false) # => [:display] | |
my_object.instance_variables # => [:@text] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment