💡 TIL: Ruby can chain methods and right-assign
29th October 2024
I just learned that ruby supports re-writing this:
total = plus_shipping(with_taxes(subtotal(items)))
As:
subtotal(items).then { |subtotal| with_taxes(subtotal) }.then { |total| plus_shipping(total) } => totalfrom davetron
More recent articles
- Ruby Sorbet is too verbose, can the syntax be improved? - 29th October 2024
- Rails migrations can include an up_only part - 29th October 2024