This file contains hidden or 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
| val n = None //> n : None.type = None | |
| val s = Some(1) //> s : Some[Int] = Some(1) | |
| val o = Option(3) //> o : Option[Int] = Some(3) | |
| o match { | |
| case Some(x) => println("Count to :" + x) | |
| case None => println("Dont count") | |
| } //> Count to :3 | |
| val s2 = Some(null) //> s2 : Some[Null] = Some(null) |
This file contains hidden or 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 ContravariantType[-T] { | |
| // some functions and fields | |
| } |
This file contains hidden or 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
| val contravariantType1: ContravariantType[String] = new ContravariantType[String] // Allowed | |
| val contravariantType2: ContravariantType[Any] = new ContravariantType[String] // Compile error | |
| val contravariantType3: ContravariantType[String] = new ContravariantType[Any] // Allowed |
This file contains hidden or 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
| val covariantType1: CovariantType[String] = new CovariantType[String] // Allowed | |
| val covariantType2: CovariantType[Any] = new CovariantType[String] // Allowed | |
| val covariantType3: CovariantType[String] = new CovariantType[Any] // Compile error |
This file contains hidden or 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 CovariantType[+T] { | |
| // some functions and fields | |
| } |
This file contains hidden or 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
| val string: Any = "sofoklis" // String is a proper subtype of any | |
| val nonVariantType1: NonVariantType[String] = new NonVariantType[String] // Allowed | |
| val nonVariantType2: NonVariantType[Any] = new NonVariantType[String] // Compile error | |
| val nonVariantType3: NonVariantType[String] = new NonVariantType[Any] // Compile error |
This file contains hidden or 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 NonVariantType[T] | |
| { | |
| // some functions and fields | |
| } |
This file contains hidden or 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
| package org.example | |
| import scala.concurrent.{ Future, Promise, future, promise } | |
| import scala.concurrent.ExecutionContext.Implicits.global | |
| class FuturesAndPromises | |
| object FuturesAndPromises { | |
| def main(args: Array[String]) { | |
| futureSample |
This file contains hidden or 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
| (x ⇒ x match { case Some(v) ~ f ⇒ !f; case None ~ f ⇒ f }) |
This file contains hidden or 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
| opt("not") ~ b_factor |