ruby - Extend send method of Object class -
i want change send method in ruby. code follow
class def send(symbol, *args) #customize code here #finally call orinial __send__ function __send__(symbol, args) end end
however, when call send function such obj.send('a_var=', 10), got error:
argumenterror: wrong number of arguments (1 0)
the error @ line call __ send__ function. how can fix error.
if want pass *args
through __send__
call individual arguments instead of array, need deconstruct there well:
__send__(symbol, *args)
Comments
Post a Comment