From: Josh Cheek Date: 2012-02-21T14:23:59+09:00 Subject: Re: 1.9.2 syntax issues --0016e6d77c7719c21b04b9729e13 Content-Type: text/plain; charset=ISO-8859-1 On Mon, Feb 20, 2012 at 10:26 PM, Eric Christopherson < echristopherson@gmail.com> wrote: > On Sun, Feb 19, 2012 at 4:08 PM, Josh Cheek wrote: > > On Sun, Feb 19, 2012 at 3:49 PM, Hal Fulton > wrote: > >> > >> I admit I still use 1.8.x more often than 1.9.x -- and I keep running > >> across > >> little things that puzzle or annoy me. > >> > >> Why is it that this statement: > >> > >> value > >> = > >> if > >> block_given? > >> yield > >> str > >> > >> else > >> > >> str.send(converter) > >> > >> end > >> > >> cannot be rewritten as: > >> > >> value = block_given? ? yield str : str.send(converter) > >> > >> > >> Just curious... > >> > >> Hal > >> > > > > It seems to be getting parsed like this > > value = block_given? ? yield(str : str.send(converter)) > > What syntactic sense does (str : str.send(converter)) make in Ruby? My > first thought was that it would think str is a symbol key, but that > doesn't seem to be a case (you can't write a hash as {foo : 'foo'}). > > Well, you can write it as {foo: 'foo'}, so I suppose it could look like you meant to write a hash but made a mistake. More likely, this is probably just an edge case in the parser's abilities. --0016e6d77c7719c21b04b9729e13 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On Mon, Feb 20, 2012 at 10:26 PM, Eric Christoph= erson <ec= hristopherson@gmail.com> wrote:
On Sun, Feb 19, 2012 at 4:08 PM, Josh Cheek <josh.cheek@gmail.com> wrote:
> On Sun, Feb 19, 2012 at 3:49 PM, Hal Fulton <rubyhacker@gmail.com> wrote:
>>
>> I admit I still use 1.8.x more often than 1.9.x -- and I keep runn= ing
>> across
>> little things that puzzle or annoy me.
>>
>> Why is it that this statement:
>>
>> =A0 value
>> =3D
>> =A0=A0=A0 if
>> block_given?
>> =A0=A0=A0=A0=A0 yield
>> str
>>
>> else
>>
>> str.send(converter)
>>
>> end
>>
>> cannot be rewritten as:
>>
>> =A0 value =3D block_given? ? yield str : str.send(converter)
>>
>>
>> Just curious...
>>
>> Hal
>>
>
> It seems to be getting parsed like this
> value =3D block_given? ? yield(str : str.send(converter))

What syntactic sense does (str : str.send(converter)) make in Ruby? M= y
first thought was that it would think str is a symbol key, but that
doesn't seem to be a case (you can't write a hash as {foo : 'fo= o'}).

<= /div>

Well, you can write it as {foo: 'foo'= ;}, so I suppose it could look like you meant to write a hash but made a mi= stake. More likely, this is probably just an edge case in the parser's = abilities.

--0016e6d77c7719c21b04b9729e13--