Skip to content

Instantly share code, notes, and snippets.

@daqing
Created April 22, 2011 06:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save daqing/936136 to your computer and use it in GitHub Desktop.
Save daqing/936136 to your computer and use it in GitHub Desktop.
understanding-class_eval-instance_eval-and-define_method
class Test
class_eval <<-END
def self.a
puts "a"
end
END
instance_eval <<-END
def b
puts "b"
end
END
instance_eval do
define_method(:c) do
puts "c"
end
end
class << self
define_method(:d) do
puts "d"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment