>-----Original Message----- >From: Joel VanderWerf [mailto:vjoel / path.berkeley.edu] >Sent: Thursday, November 23, 2006 8:55 PM >To: ruby-talk ML >Subject: Re: Rubyish inst.var initializations > >Daniel Schierbeck wrote: >> On Thu, 2006-11-23 at 10:04 +0900, Victor "Zverok" Shepelev wrote: >... >>> Then I note (through profiler) various push_XXX spend too much time in >>> checking is @XXX_list initialized. Then I change it: >... > >Sounds like Victor was interested in avoiding the ||= in each access. >The following still does that check, though it is nice clean code, and >preferable unless profiling shows it to be a bottleneck: > >> class MyClass >> def something_list >> @something_list ||= [] >> end >> >> def push_something(obj) >> something_list << obj >> end >> end Right. And Ara's solution is completely great (I've already said this yesterday, but don't see those mail in list - interesting, why?). V.