P
Pavel Smerk
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.
= can I somehow make ruby produce warnings on 1 == '1' (number ==
string) like comparisons? In Perl true, in Ruby false. Many my mistakes
are of this kind and as these values seems same on output. ;-)
= why I can use {|...| ...} as argument for map, each etc., but I cannot
write foo = {|...| ...}, though I can write bar = [...] or bar = {...}?
Thanks,
P.
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.
= can I somehow make ruby produce warnings on 1 == '1' (number ==
string) like comparisons? In Perl true, in Ruby false. Many my mistakes
are of this kind and as these values seems same on output. ;-)
= why I can use {|...| ...} as argument for map, each etc., but I cannot
write foo = {|...| ...}, though I can write bar = [...] or bar = {...}?
Thanks,
P.