From: Gene Tani Date: 2006-03-15T06:28:45+09:00 Subject: Re: some questions on language syntax Pavel Smerk wrote: > Hi, I'm new to this language and as I'm Perl user, some things seems > strange to me: > > = %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. > > = 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. > use #sort_by like: Enumerable#sort_by { |obj| obj.fld1, obj.fld2 } this list give good, quick, *accurate* answers, no?