tags:

views:

76

answers:

1

In C# you can write:

var alphaTask = Task.Factory.StartNew(() =>
{
     return someWork(n);
});
// ... do some other work, and later get the result from the task
var res = alphaTask.Result;

How would this simple construction look like in Scala?
Thank you.

+6  A: 

In Scala 2.8, the simplest equivalent would be

val future = Futures.future{
                someWork(n)
           }
// ... do some other work, and later get the result from the task
val res = future();  
Dave Griffith