💡 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
- pick is the single-value version of pluck in Rails - 26th November 2024
- Rails ActiveRecord has a .sole method - 26th November 2024
- NASA's Dragonfly probe to Saturn's Titan in 2028 - 26th November 2024