This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Contravariance[-T] | |
//defined class Contravariance | |
val contAny:Contravariance[Any] = new Contravariance[String] | |
/* | |
<console>:8: error: type mismatch; | |
found : Contravariance[String] | |
required: Contravariance[Any] | |
val contAny:Contravariance[Any] = new Contravariance[String] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Covariance[+T] | |
val coAny:Covariance[Any] = new Covariance[String] | |
// coAny: Covariance[Any] = Covariance@33a626ac | |
val coString:Covariance[String] = new Covariance[Any] | |
/*<console>:8: error: type mismatch; | |
found : Covariance[Any] | |
required: Covariance[String] | |
val coString:Covariance[String] = new Covariance[Any] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def bbb:Future[List[String]] = future { List("hi","there") } | |
def failedFuture:[List[String]] = future{ throw new RuntimeException("~~") } // or Future.failed(throw new ~~()) | |
def action1 = Action { | |
Async{ | |
bbb map { | |
list => //list:List[String] | |
Ok(list.mkString("~ ")) | |
} |