2 ms·
Ruby equivalent: class Whatever; def method_missing *_; self; end; end Sample usage: irb(main):001:0> Whatever.new.foo.bar.baz - 2 => #<Whatever:0x007f
by vemv 9y ago
Ruby equivalent:
class Whatever; def method_missing *_; self; end; end
Sample usage:
irb(main):001:0> Whatever.new.foo.bar.baz - 2
=> #<Whatever:0x007fd7ed0a2a68>
- slmgc 9y agoYep, it's way easier to implement in some other languages. Btw, is it callable as well? Can you do Whatever.new().foo.bar().baz with it?
- vemv 9y ago`.foo.bar` are method calls (parenses are optional in Ruby)
- baddox 9y agoNope. Ruby doesn’t support the function call paren syntax for anything other than methods. You could do stuff like Whatever.new().foo.().bar[] though.
- djur 9y agofoo, bar, and baz are all methods here, so you can use parens.