Being Lazy with ActiveRecord
In programming language terms, “laziness” refers to code whose evaluation is delayed until the last possible moment. This strategy can have several benefits. For example:
nums = (1..1_000_000).lazy
squares = nums.map { |x| x * x }
squares.take_while {…