Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat are the precise rules for when you can omit parenthesis, dots, braces, = (functions), etc.?
    primarykey
    data
    text
    <p>What are the precise rules for when you can omit (omit) parentheses, dots, braces, = (functions), etc.?</p> <p>For example, </p> <pre><code>(service.findAllPresentations.get.first.votes.size) must be equalTo(2). </code></pre> <ul> <li><code>service</code> is my object</li> <li><code>def findAllPresentations: Option[List[Presentation]]</code></li> <li><code>votes</code> returns <code>List[Vote]</code></li> <li><em>must</em> and <em>be</em> are both functions of specs</li> </ul> <p>Why can't I go:</p> <pre><code>(service findAllPresentations get first votes size) must be equalTo(2) </code></pre> <p>?</p> <p>The compiler error is:</p> <blockquote> <p>"RestServicesSpecTest.this.service.findAllPresentations of type Option[List[com.sharca.Presentation]] does not take parameters"</p> </blockquote> <p>Why does it think I'm trying to pass in a parameter? Why must I use dots for every method call?</p> <p>Why must <code>(service.findAllPresentations get first votes size)</code> be equalTo(2) result in:</p> <blockquote> <p>"not found: value first"</p> </blockquote> <p>Yet, the "must be equalTo 2" of <code>(service.findAllPresentations.get.first.votes.size)</code> must be equalTo 2, that is, method chaining works fine? - object chain chain chain param.</p> <p>I've looked through the Scala book and website and can't really find a comprehensive explanation.</p> <p>Is it in fact, as Rob H explains in Stack Overflow question <em><a href="https://stackoverflow.com/questions/1006967/scala-which-characters-can-i-omit">Which characters can I omit in Scala?</a></em>, that the only valid use-case for omitting the '.' is for "operand operator operand" style operations, and not for method chaining?</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.
 

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