Skip to content

Instantly share code, notes, and snippets.

@thijsnado
Created April 6, 2018 14:20
Show Gist options
  • Save thijsnado/4a452704035ea8c1cbf07ed0734bc993 to your computer and use it in GitHub Desktop.
Save thijsnado/4a452704035ea8c1cbf07ed0734bc993 to your computer and use it in GitHub Desktop.
void.rb
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