Created
April 6, 2018 14:20
-
-
Save thijsnado/4a452704035ea8c1cbf07ed0734bc993 to your computer and use it in GitHub Desktop.
void.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.module_eval do | |
def self.void(method_name) | |
old_method_name = :"old_#{method_name}" | |
alias_method old_method_name, method_name | |
private old_method_name | |
define_method method_name do | |
send(old_method_name) | |
nil | |
end | |
end | |
end | |
class Foo | |
void def fuck_implicit_returns | |
puts "fuck implicit returns" | |
"can't return this!!" | |
end | |
end | |
value = Foo.new.fuck_implicit_returns | |
puts("value is: #{value}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment