From: "David A. Black" Date: 2004-08-07T01:32:31+09:00 Subject: Re: %w for symbols Hi -- On Sat, 7 Aug 2004, Ara.T.Howard wrote: > On Fri, 6 Aug 2004, David A. Black wrote: > > > That actually points to another thing I was wondering about, namely, > > what would be the %?{ } equivalent of: > > > > ["abc".intern, "hi there".intern] > > > > You couldn't do (using %m as a placeholder here): > > > > %m{abc hi there} > > > > It would have to be > > > > %m{abc "hi there"} > > > > I'm just wondering whether that would lead down a path of escape syntax that > > would make it less streamlined. > > we are already down that path > > jib:~ > ruby -r yaml -e 'y %w(abc hi there)' > --- > - abc > - hi > - there > > eg. there is not %w equivalent of ["abc", "hi there"] and this has not been a > problem. OK... but that's not exactly the same as the question of the costs and benefits of introducing a new %? construct. > i don't think it would be a problem for symbols either since you could never > really need to do > > obj.send 'hi there'.intern > > since you could never define > > def hi there > 42 > end > > and you could never need > > hash['hi there'.intern] > > since you could not type > > hash[:hi there] You could do it like this: irb(main):007:0> h = {} => {} irb(main):008:0> h["hi there".intern] = 1 => 1 irb(main):009:0> h[:"hi there"] => 1 (i.e., not being able to do [:hi there] doesn't rule this out) > well, never is a strong word - but this issue seems even more unlikely to > occur than needing to do it via a wordlist since symbols containing white > space are far and few between. Maybe, but people are always talking about using symbols to speed up hashes, etc.... And symbols *can* act that way, so not accomodating it in some way would be somewhat arbitrary. David -- David A. Black dblack@wobblini.net