This is in a shared library, I have to make this backward compatible.
Original method
def rrp_exc_sales_tax=(num)
price_set(1, num, currency_code)
end
Need to enhance and add currency_code
def rrp_exc_sales_tax=(num, currency_code=nil)
print "num=#{num}"
print "currency_code=#{currency_code}"
price_set(1, num, currency_code)
end
some_class.rrp_exc_sales_tax=2, "USD"
num=[2, "USD"]
currency_code=
No value gets assigned to currency_code
If you want it to be backwards compatible, leverage on the powers of the array:
def rrp_exc_sales_tax=(arr)
num, currency_code = arr
price_set(1, num, currency_code)
end
some_class.rrp_exc_sales_tax=2, "USD"
# => num=2
# => currency_code="USD"
some_class.rrp_exc_sales_tax=2
# => num=2
# => currency_code=nil
Because it's meant to look like a simple assignment operation. If that operation needs to be parameterized, it makes more sense to make it look like a method call instead. Also, having multi-parameter assignment statements complicates the language grammar.
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