Last active
January 30, 2017 23:59
-
-
Save vkostyukov/3a91ad57b7dffffd12cf00b81336bd33 to your computer and use it in GitHub Desktop.
Java-friendly ADTs in Scala
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
// In Scala | |
sealed abstract class Toggle | |
object Toggle { | |
private case object ON extends Toggle | |
private case object OFF extends Toggle | |
def On: Toggle = ON | |
def Off: Toggle = OFF | |
} | |
// In Java | |
Toggle t = Toggle.Off() | |
Toggle t = Toggle.On() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment