From: Brian Candler Date: 2004-10-01T17:33:22+09:00 Subject: Re: Proc.new(method)? (was Re: Funtionality of 'case'-Expression) On Fri, Oct 01, 2004 at 09:39:55AM +0900, Markus wrote: > > Fair enough. I'd make those criteria constants, rather than local variables > > - perhaps in all-caps to avoid confusion with classes like Float. > > What's wrong with them being variables? They are first class > citizen, after all. We can pass them around, change their value I was just thinking of efficiency. You can declare NEGATIVE = Criterion.new { |x| x < 0 } in a module or class definition, and a single persistent object is created. However if you do this in a local variable, which by necessity is within a method body, then every time you call that method a fresh Criterion object will be created. The constant also lets you share the same Criterion object between methods. > (imagine instead of "negative" and "prime" criteria like > "acceptable_to_most_voters" or "not_too_ugly" that may have > (complicated) values constructed elsewhere) and in general do anything > we want with the values. > So why artificially constrain their "storage class"? Sure, if you need a different Criterion object at different times, then refer to it from a (local variable / instance variable / whatever) Regards, Brian.