In Java, I can do this:
Runnable task = () -> { System.out.println("Task is running"); };
But how to come to Scala I can not 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
source
share