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
| import akka.actor.Actor | |
| import akka.actor.OneForOneStrategy | |
| import akka.actor.SupervisorStrategy.Stop | |
| import akka.actor.ActorSystem | |
| import akka.actor.Props | |
| import akka.actor.ActorInitializationException | |
| class TestActorParent extends Actor { | |
| override val supervisorStrategy = OneForOneStrategy() { | |
| case a: ActorInitializationException => { |
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
| /** | |
| * A simple Java data class with two immutable fields. If I want | |
| * to add a third field (e.g. seconds), I have to update a ton of | |
| * places and remember them all, because a compiler will not tell | |
| * you what you missed. If I generate equals/hashCode/toString, I | |
| * have to remember to do so with every change. And I cannot | |
| * overload constructors and assume default values for parameters, | |
| * because in this class, each field is an int and they'd have the | |
| * same signature, so I have to use the Builder Pattern to do | |
| * default values. This is a maintenance nightmare compared to |
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
| scala> import cats._, cats.instances.all._ | |
| import cats._ | |
| import cats.instances.all._ | |
| scala> :paste | |
| // Entering paste mode (ctrl-D to finish) | |
| sealed trait TrafficLight | |
| object TrafficLight { | |
| def red: TrafficLight = Red |
OlderNewer