Skip to content

Instantly share code, notes, and snippets.

@dansteele
Last active January 12, 2016 17:10
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 dansteele/650111ec1baa7f0d906e to your computer and use it in GitHub Desktop.
Save dansteele/650111ec1baa7f0d906e to your computer and use it in GitHub Desktop.
Dynamic stuff for Austin
class Person
def initialize(name)
@name = name
end
end
austin = Person.new("Austin")
austin.define_singleton_method "speak" do
"Hi, my name is #{@name}"
end
austin.speak
#=> Hi, my name is Austin
Person.class_eval do
def speak
"Hi my name is #{@name}"
end
end
dan = Person.new("Dan")
dan.speak
#=> "Hi, my name is Dan"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment