Created
March 8, 2019 09:58
-
-
Save rberenguel/fa17c5a3083af64e41d097d929a78239 to your computer and use it in GitHub Desktop.
Weird companion object issue in Scala 2.11 vs 2.12
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
case class Country(name: String) { | |
private val ThreeLetterValidCountries = List("FOO", "BAR") | |
def valid: Option[Country] = | |
if (ThreeLetterValidCountries.contains(name.toUpperCase)) Some(this) else None | |
} | |
object Country { | |
def apply(name: String): Country = new Country(name.toUpperCase) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment