Skip to content

Instantly share code, notes, and snippets.

@tenderlove
Forked from haileys/trololol.rb
Last active December 21, 2015 06:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tenderlove/6264425 to your computer and use it in GitHub Desktop.
Save tenderlove/6264425 to your computer and use it in GitHub Desktop.
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