From: Joel VanderWerf Date: 2006-11-24T03:54:30+09:00 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 -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407