From: Justin Bailey Date: 2006-03-29T07:23:57+09:00 Subject: Opposite of ||= pattern? ------=_Part_10670_29537698.1143584632451 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline A cheap just-in-time initialization trick is the "||=3D" trick: def add_name(n) @name ||=3D Array.new @name << n end Now, how would you do the opposite of this pattern? More specifically, what kind of construct would evaluate to a true value once, and then nil from then on? I came upon this in the context of for loops, where I want a one-time "starting" value to be present the first time through the loop, then nil. And I wanted to do it in a cool way - i.e. not just assign the value to nil at the end of the loop, though of course that is the easiest way. Any thoughts? Justin ------=_Part_10670_29537698.1143584632451--