Skip to content

Instantly share code, notes, and snippets.

@codesword
Created June 5, 2016 11:55
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 codesword/4f0f2473caf4d9e0a796d9ccc4fb8927 to your computer and use it in GitHub Desktop.
Save codesword/4f0f2473caf4d9e0a796d9ccc4fb8927 to your computer and use it in GitHub Desktop.
class Person
c = %q{def company; "Andela"; end}
instance_eval(c)
def initialize
@name = "Ikem Okonkwo"
end
def make
instance_eval("def name; 'Ikem Okonkwo'; end")
end
end
p = Person.new
p.name #=> undefined method error
p.make
p.name #=> "Ikem Okonkwo"
p.company #=> undefined method error
Person.company #=> "Andela
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment