title: How to write lambda for java.UnaryOperator<T> interface in Scala?
body: <p>I've written this code in scala:</p>
  
  <pre><code>def push(x: T): Unit = ref.updateAndGet(new UnaryOperator[List[T]] {
    override def apply(t: List[T]): List[T] = x :: t
  })
  </code></pre>
  
  <p>And want to rewrite it in a more functional way, like</p>
  
  <pre><code>def push(x: T): Unit = ref.updateAndGet(t =&gt; x::t)
  </code></pre>
  
  <p>But it doesn't work. Is it possible to do such casting correctly? </p>