Skip to content

Instantly share code, notes, and snippets.

@shivabhusal
Created June 20, 2017 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shivabhusal/0141700460361372bd2f0ada4668c206 to your computer and use it in GitHub Desktop.
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
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