💡 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
- with_defaults is a better named alias - 28th April 2025
- Bundler can be configured to auto install - 28th April 2025
- React in Rails is gaining momentum with Inertia - 14th April 2025