I have defined the following object which I want to sort a string concurrently.
object QuoteFuture extends App {
val wordsStr : String = "Lorem ipsum dolor ..."
import scala.concurrent._
import ExecutionContext.Implicits.global
val f : Future[String] = Future {
val wordsArr = wordsStr.split("\\s+")
wordsArr.sorted // <<<<< Compiler error from here (line 15)
}
f.onComplete(t => {
if (t.isSuccess) {
println(s"words sorted: ${t.get}")
} else {
println("could not sort words")
}
})
}
I have omitted the entire string for brevity. When I attempt to run the code above, I get the following compilation error:
Error:(15, 14) polymorphic expression cannot be instantiated to expected type;
found : [B >: String]Array[String]
required: String
wordsArr.sorted
I have no idea what this means.