<p>Instead of writing</p>

<pre><code>((x: Double) =&gt; (((y: Double) =&gt; y*y))(x+x))(3)
</code></pre>

<p>I would like to write something like</p>

<pre><code>((x: Double) =&gt; let y=x+x in y*y)(3)
</code></pre>

<p>Is there anything like this sort of syntactic sugar in Scala?</p>

Indeed there is: it's called "
```
val
```
".  :-)
```
```
({ x: Double =>
  val y = x + x
  y * y
})(3)
```
```
The braces are of course optional here, I just prefer them to parentheses when defining functions (after all, this isn't Lisp).  The
```
val
```
keyword defines a new binding within the current lexical scope.  Scala doesn't force locals to define their own scope, unlike languages such as Lisp and ML.
Actually,
```
var
```
also works within any scope, but it's considered bad style to use it.