Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Actually, on second reading, maybe this is the key:</p> <blockquote> <p>With methods which only take a single parameter, Scala allows the developer to replace the . with a space and omit the parentheses</p> </blockquote> <p>As mentioned on the blog post: <a href="http://www.codecommit.com/blog/scala/scala-for-java-refugees-part-6" rel="nofollow noreferrer">http://www.codecommit.com/blog/scala/scala-for-java-refugees-part-6</a> .</p> <p>So perhaps this is actually a very strict "syntax sugar" which <em>only</em> works where you are effectively <em>calling a method, on an object, which takes one parameter</em>. e.g.</p> <pre><code>1 + 2 1.+(2) </code></pre> <p>And nothing else.</p> <p>This would explain my examples in the question.</p> <p>But as I said, if someone could point out to be exactly where in the language spec this is specified, would be great appreciated.</p> <p>Ok, some nice fellow (paulp_ from #scala) has pointed out where in the language spec this information is:</p> <blockquote> <p>6.12.3: Precedence and associativity of operators determine the grouping of parts of an expression as follows.</p> <ul> <li>If there are several infix operations in an expression, then operators with higher precedence bind more closely than operators with lower precedence.</li> <li>If there are consecutive infix operations e0 op1 e1 op2 . . .opn en with operators op1, . . . , opn of the same precedence, then all these operators must have the same associativity. If all operators are left-associative, the sequence is interpreted as (. . . (e0 op1 e1) op2 . . .) opn en. Otherwise, if all operators are rightassociative, the sequence is interpreted as e0 op1 (e1 op2 (. . .opn en) . . .).</li> <li>Postfix operators always have lower precedence than infix operators. E.g. e1 op1 e2 op2 is always equivalent to (e1 op1 e2) op2.</li> </ul> <p>The right-hand operand of a left-associative operator may consist of several arguments enclosed in parentheses, e.g. e op (e1, . . . ,en). This expression is then interpreted as e.op(e1, . . . ,en).</p> <p>A left-associative binary operation e1 op e2 is interpreted as e1.op(e2). If op is rightassociative, the same operation is interpreted as { val x=e1; e2.op(x ) }, where x is a fresh name.</p> </blockquote> <p>Hmm - to me it doesn't mesh with what I'm seeing or I just don't understand it ;)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload