In message "[ruby-talk:01219] Re: Trivial FAQ bug"
    on 00/02/01, "Conrad Schneiker" <schneiker / jump.net> writes:

|For instance, besides noting that Ruby doesn't treat "" as false like Perl
|does, is there a good language design or programming practice reason for
|this? Being new to Ruby and not being familiar with the reasons for such
|things, it seems to me that Perl's treatment of "" in conditions is somewhat
|less error-prone and somewhat better follows the principle of least
|surprise.

Mostly for performance reason, currently false test is done by one
bitwise operation.  If "" etc. made false, false test would be far
more complex.

|Since I am still learning Ruby, I thought it would be useful learning
|exercise to do a "Ruby Cookbook" FAQ for Perl programmers (an idea I got
|from a recent suggestion in the Python newsgroup to in effect translate the
|Perl Cookbook into Python). Any interest in this?

I'd like to see a Ruby Cookbook.  Of cource, I'll help to make one.

| One of the first things I
|would like to include would be examples of Ruby equivalents for Perl's map
|and grep functions, which I make heavy use of.

Enumerable's collect and select replace Perl's map/grep.

e.g.

  [1,2,3,4].collect{|x| x*2}            #=> [2,4,6,8]
  [1,2,3,4].select{|x| x % 2 == 0}      #=> [2,4]

							matz.