-
-
Save tenderlove/6264425 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 | |
def static x | |
define_singleton_method(x) { | |
instance_method(x).bind(new).call | |
} | |
end | |
end | |
class Foo | |
public static int def foo | |
10 | |
end | |
end | |
Foo.foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment