Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Foo
- end
- class Bar
- end
- def populate(target, number)
- target.class.send(:define_method, "speak") do
- p number
- end
- end
- populate(Foo, 1)
- populate(Bar, 2)
- Foo.speak # expected output: 1; got output: 2
- Bar.speak # expected output: 2; got output: 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement