In Java I can do this:
Runnable task = () -> { System.out.println("Task is running"); };
But how come in Scala I can't do the same!
val task: Runnable = () => {println("Task is running")}
I get a compiler error! I am using Scala version 2.11.8.
type mismatch; found : () => Unit required: Runnable
scala> val task: Runnable = () => {System.out.println("Task is running")}givestask: Runnable = $$Lambda$1011/1678449328@2917b6cbprintln(), by the way