From: Logan Capaldo Date: 2006-06-06T12:29:29+09:00 Subject: Re: An alternative to the class Foo < Struct.new(vars) idiom and SuperStruct On Jun 5, 2006, at 5:59 PM, Steven Lumos wrote: > Logan Capaldo writes: >> This is why I kind of like how in Perl => is just a synonym for comma >> (it is in ruby too, at least for Hash literals, the problem being >> that it forces a hash literal). then > > I stopped using Perl when I started using Ruby, but I seem to recall > that => in Perl does more than comma. E.g. {a => 1, b => 2} is mostly > equivalent to {'a', 1, 'b', 2}. > > Ruby doesn't do the magic quoting. > > Steve > > True, but in perl you have to "force" the evaluation of variables anyway. => auto-quoting only works for barewords (\w+), as soon as you do something like "Hello, world" => 1 it's exactly the same as "Hello, world", 1 Whether or not it turns into a hash or an array is of course dependant on the left-hand side. %hash = ( "a" => 1 ); @array = ( "a" => 1 ); Which I think may as well be equivalent to ruby's { "a" => 1 } [ "a" => 1 ] But (un?)fortunately they are not. [ "a" => 1 ] in ruby is [ { "a" => 1 } ] In fact in ruby => isn't equiv to comma, it's more like comma is equiv to => when surrounded by { }. Getting way off topic here.