A } final case class Some[+A](x: A) extends Option[A] { def get = x } case object None extends Option[Nothing] { def get = throw new NoSuchElementException("None.get") }
A } final case class Some[+A](x: A) extends Option[A] { def get = x } case object None extends Option[Nothing] { def get = throw new NoSuchElementException("None.get") }
producer = future { val r = produceSomething() p success r continueDoingSomethingUnrelated() } val consumer = future { startDoingSomething() f onSuccess { case r => doSomethingWithResult() } }
и описание поведения • Общение между акторами только через сообщения с неизменяемыми данными • Акторы могут создавать других акторов и управлять ими в случае исключительных ситуаций
case "test" => log("received test") case _ => log("received unknown message") } } object Main extends App { val system = ActorSystem("MySystem") val myActor = system.actorOf(Props[MyActor], name = "myactor") myActor ! "test" }
{ xs match { case Nil => None case head :: tail => if (p(head)) Some(head) else find(tail, p) } } trait Provider { def smth: Int } class LazyOne extends Provider { lazy val smth = { ??? } } assert(assertion: Boolean, message: => Any): Unit assert(true, { ??? }) assert(false, { ??? }) implicit class RockString(str: String) { def rock() = ??? } "foo".rock() 2.10 package my class Foo { private[this] val x: Int = ??? private[Foo] val y: Int = ??? private[my] val z: Int = ??? } val xml = <and><much>More!</much></and>