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

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -