नीचे दिया गया कोड संकलित नहीं करता है और मुझे नहीं पता कि इसे कैसे ठीक किया जाए।Play 2.1.1 async अनुरोधों और वायदा का उपयोग कैसे करें
def doAsync(n: Int) = Action {
import scala.concurrent.ExecutionContext.Implicits.global
Async {
val f1 = Future.successful(n)
f1.map(x => x match {
case 10 => Ok("first")
case _ => {
val f2 = Future.successful(n)
f2.map(y => Ok("second"))
}
})
}
}
लाइन f2.map(y => Ok("second"))
संकलन त्रुटि पैदा करता है:
प्रकार मेल नहीं खाता; पाया: scala.concurrent.Future [play.api.mvc.SimpleResult [स्ट्रिंग]] की आवश्यकता: play.api.mvc.Result
कोर "business logic" is: f2
केवल if n is not 10
चलाना चाहिए।