On 2003-08-09 19:31:49 +0900, Kent Dahl wrote:
> That is the beauty of only nil and false being false...

Yep. In Perl it's a common idiom to do something like
	@a = sort { $a->foo <=> $b->foo || $a->bar <=> $b->bar } @a;
to sort @a because 0 is also false. But the Ruby Way seems to be less
hackish to me than Perl's approach.

Consider this in Perl:

0 || "false" => "false"

"0" || "false" => "false"

"00" || "false" => "00"

00 || "false" => "false"

The last example interprets 00 as octal 0 and thus false, but the string
"00" is just a string that consists of two chars and it happens to be
true. The string "0" is interpreted as zero none the less. In any case
you could add 1 to both so that a number is returned.

"0" + 1 => 1
"00" + 1 => 1

It's funny that Ruby looks like Perl but if you go into the details you
realize that it has a much better way to achieve the nice things without
having to carry the nasty things.

-- 
Premature optimization is the root of all evil in programming.
  -- C.A.R. Hoare