Skip to content

Instantly share code, notes, and snippets.

@josep2
Created November 22, 2019 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josep2/d1c933fd336965df3656cc5d9f3f90a4 to your computer and use it in GitHub Desktop.
Save josep2/d1c933fd336965df3656cc5d9f3f90a4 to your computer and use it in GitHub Desktop.
sealed abstract class Action extends Product with Serializable
object Camera {
final case class Picture(iso: Int, aperture: Double) extends Action
final case class Video (duration: Int) extends Action
}
def actionHandler(action: Action): Unit = action match {
case Camera.Picture(iso, app) => print(s"Took photo with iso: $iso and aperture $app")
case Camera.Video(dur) => print(s"Took video for $dur seconds")
}
val j = Camera.Video(10)
val g = Camera.Picture(200, 2.6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment