Skip to content

Instantly share code, notes, and snippets.

@gr33n7007h

gr33n7007h/w.rb Secret

Created April 3, 2018 15:15
Show Gist options
  • Save gr33n7007h/dd940a9a6fc99124704c64360035d4c1 to your computer and use it in GitHub Desktop.
Save gr33n7007h/dd940a9a6fc99124704c64360035d4c1 to your computer and use it in GitHub Desktop.
w
>>
>> class X def foo() str.upcase end end
=> :foo
>>
>> Bar = Struct.new(:str) do
| define_method(:foo, X.instance_method(:foo))
| end
TypeError: bind argument must be a subclass of X
from (pry):3:in `define_method'
>>
>> Pointer[dlwrap X][0,8] = Pointer[dlwrap Module.new][0,8]
=> "C\x00\x00\x00\x00\x00\x00\x00"
>>
>> Bar = Struct.new(:str) do
| define_method(:foo, X.instance_method(:foo))
| end
=> Bar
>>
>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment