-
-
Save haileys/6264387 to your computer and use it in GitHub Desktop.
This file contains 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
module Kernel | |
def int(mid) | |
meth = instance_method(mid) | |
define_method(mid) { |*args, &bk| | |
val = meth.bind(self).call(*args, &bk) | |
raise TypeError, "#{mid} did not return an Integer" unless val.is_a? Integer | |
val | |
} | |
mid | |
end | |
end | |
class Foo | |
public int def foo | |
10 | |
end | |
end | |
Foo.new.foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment