💡 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
- React in Rails is gaining momentum with Inertia - 14th April 2025
- Query optimization in rails - 14th April 2025
- Ruby's clamp method reduces conditionals - 24th February 2025