Or it might be better to say that '+' without '.' moves the interpreter to
a different mode, where '.+' is the more general default behaviour.

On Wed, 14 Oct 2015 at 16:49 Doug Lake-Hammond <d.lakehammond / gmail.com>
wrote:

> Basically '.+' seems to move the interpreter to a different mode where it
> assumes whitespace-separated tokens are arguments of the method token to
> the left, such as 'puts get_thing a, b'. Even here there are limitations on
> what you can get away with; the interpreter will very deliberately refuse
> to guess what 'foo 1, bar 2, 3' is supposed to mean.
>
> There are also operator precedence rules to be aware of here. The 'if'
> keyword is a binary operator, on the same level as 'or'/'and', in fact it's
> basically just 'and' with the operand evaluation order reversed. Note the
> difference in evaluation order from '||'/'&&':
>
> 2.2.3 :001 > 1 .+ [0,2,1].index 1 if 1==1
>  => 3
> 2.2.3 :002 > 1 .+ [0,2,1].index 1 and 1==1
>  => true
> 2.2.3 :003 > 1 .+ [0,2,1].index 1 && 1==1
> TypeError: nil can't be coerced into Fixnum
> from (irb):3:in `+'
> from (irb):3
>
> You might get a more thorough answer regarding interpreter rules on
> ruby-lang if you ask nicely enough :)
>
> Cheers,
> Doug
>
> On Wed, 14 Oct 2015 at 16:30 botp <botpena / gmail.com> wrote:
>
>> On Wed, Oct 14, 2015 at 4:14 PM, Doug Lake-Hammond
>> <d.lakehammond / gmail.com> wrote:
>> > Consider the expression a = b.fetch c + d.foo e + f. Is that supposed
>> to be
>> <snip>..
>>
>> hi doug, thanks. but would you know why ruby does not fail on this dot
>> expression?
>>
>> > 1 .+ [0, 2,1].index 1 if 1==1
>> => 3
>>
>> kind regards
>> --botp
>>
>