I came across some results in a program I was writing that confused me. It is my understanding parens are not normally needed (i.e. obj.method1.method2 is as good as (obj.method1).method2). In addition all operators are really method calls so I expected them to behave similarly.
So imagine my surprise that "S"+"R".downcase resulted in Sr as did "S".+"R".downcase however "S".send(:+, "R").downcase finally gave me the expected output sr
Is this because the operator shortcuts are treated differently or is there some other mechanic at work here that I am missing?
Edit: The question isn’t about the order of operations that resulted in the answer, that’s obvious. The question was WHY the expression was resolved in that order.
.has higher precedence than+and is evaluated first.("S"+"R").downcaseworks too.