Bernhard 'elven' Stoeckner wrote:
> Pavel Smerk scribbled on Tuesday 14 Mar 2006 21:50:
>>= %w{a b} produces ['a', 'b']. Is there some similarily easy way for
>>{'a' => 'b'}? Or, can I transform an array to some "list"? I can use
>>Hash['a', 'b'], but not Hash[%w{...}], because I cannot generate a list,
>>only an array.
> 
> You can, however, expand the array:
>  Hash[*%w{a b c d}] yields {"a"=>"b", "c"=>"d"}

Oh, that's great!!! How could I not notice that? ;-)

>>= how can I do 'perlish' a[1] <=> b[1] || a[2] <=> b[2] if I want
>>compare a and b accordind to some my own rules, i.e. if a[1] == b[2],
>>"return" a[2] <=> b[2]? In Ruby this is not possible, because 0 is true.
> 
> irb(main):006:0> 0 == true
> => false
> 
> 0 is not true :)

Well, to be more precise, 0 is not equal to false (as is in Perl). :-)

So, how do you do a[1] <=> b[1] || a[2] <=> b[2]? Or, may be a.x <=> b.y 
|| a.w <=> b.z would be better --- I don't want to suppose anything 
about the internal structure of a and b now. However, Jim Weirich's
(a[1] <=> b[2]).nonzero? || a[2] <=> b[2] seems OK (and it's even in 
RDoc for Numeric#nonzero? ;-).

Gene Tani wrote:
 > this list give good, quick, *accurate* answers, no?

;-) Must agree with this. Thank for all suggestions, they are very 
valuable for me.

P.