From: Adam Gardner Date: 2009-04-09T23:33:18+09:00 Subject: Re: Hash questions Hunt Jon wrote: > When I run: > > p {"foo" => 1, "bar" => 2, "baz" => 3 } > > I get an error. > > But when I run: > > x = {"foo" => 1, "bar" => 2, "baz" => 3 } > p x > > There's no error. > > What's the difference between the two? > > John From what I can tell, ruby is interpreting the beginning of your hash as the beginning of a block, instead; p({"foo" => 1, "bar" => 2, "baz" => 3 }) works as intended. This is seems like a bug to me, although whether it's a bug with the parser (finding a block where it should be looking for a hash literal), a bug with p (asking for a block when it doesn't use one) or the documentation (failing to mention that p accepts a block), I'm not sure. -- Posted via http://www.ruby-forum.com/.