03-11-2011, 04:41 AM
Ah, be forewarned about aliases. They are tricky devils.
Picture an method like this:
It adds 3 to what is entered. And then returns it. Aliasing this should be like this...
This new alias retrieves the value gained from the original method, and then adds 40 to it before returning it. This way, you can alter values that are generated and returned by methods.
Picture an method like this:
Code:
def method_one(x)
return_val = x + 3
return x
end
It adds 3 to what is entered. And then returns it. Aliasing this should be like this...
Code:
alias new_method_one method_one
def method_one(x)
value_new = new_method_one(x)
value_new += 40
return value_new
end
This new alias retrieves the value gained from the original method, and then adds 40 to it before returning it. This way, you can alter values that are generated and returned by methods.