From: Ryan Paul Date: 2004-06-13T05:23:38+09:00 Subject: Re: Appropriate use of camelCase On Sun, 13 Jun 2004 05:05:59 +0900, Joel VanderWerf wrote: > Ryan Paul wrote: >> Part of what makes ruby powerful is the fact that it doesnt sacrifice >> power and brevity to increase readability. Ruby is downright unintuitive >> in some places, with extremely rewarding consequences. >> >> For instance, compare ruby blocks to python list comprehensions: >> >> lst.reject {|x| not x.upcase.include? n.upcase } >> >> vs. >> >> [x for x in lst if n.upper in x.upper] > > Unintuitive? It might help to avoid the double negative... > > lst = %w{ foo BaR baZ foobar } > n = "bar" > > # original > p lst.reject {|x| not x.upcase.include? n.upcase } > > # no double negative > p lst.select {|x| x.upcase.include? n.upcase } > > # even better :) > p lst.grep(/#{n}/i) > > To know ruby is to love it. *blinks* Thanks. I had been looking for a way to avoid the double negative, and I got frustrated because map doesnt behave the same way it does in python. I hadnt realized the select function does that. I need to spend more time with the docs. Regardless, I think my intial claim holds up. The example with grep is beautifully concise, but the meaning doesnt seem all that intuitive. Higher learning curve, greater value - ultimately A Good Thing(tm). -- SegPhault