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 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))

You can get around it with parens like this:
value = block_given? ? (yield str) : str.send(converter)

Or by using the if/then/else/end keywords
value = if block_given? then yield str else str.send(converter) end