Normally to override a method I would just alias it:
alias original_method_name method_name
I have now come across a method that looks like this:
def []=(key, value)
end
And I am not sure how to alias this one.
Maybe I didn't understand the question, but
>> class Hash
.. alias :foobar :[]=
.. end
=> nil
>> h = Hash.new
=> {}
>> h.foobar(:a, 1)
=> 1
>> h
=> {:a=>1}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With