Skip to content

Instantly share code, notes, and snippets.

@YanhaoYang
Last active May 21, 2016 08:44
Show Gist options
  • Save YanhaoYang/8419d994b8b47f84cc6556cbc3b3ec31 to your computer and use it in GitHub Desktop.
Save YanhaoYang/8419d994b8b47f84cc6556cbc3b3ec31 to your computer and use it in GitHub Desktop.
Redefine a method by opening the class
class A
def hi
puts 'hi'
end
end
a = A.new
a.hi
# => "hi"
class A
def hi
puts 'hi redefined'
end
end
a.hi
# => "hi redefined"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment