Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Spell: Dynamic Method
# =====================
# Spell: Dynamic Method
# =====================
# Decide how to define a method at runtime.
class C
C.class_eval do
define_method :my_method do
"a dynamic method"
obj =
obj.my_method # => "a dynamic method"
# For more information:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment