Skip to content

Instantly share code, notes, and snippets.

@rberenguel
Created March 8, 2019 09:58
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 rberenguel/fa17c5a3083af64e41d097d929a78239 to your computer and use it in GitHub Desktop.
Save rberenguel/fa17c5a3083af64e41d097d929a78239 to your computer and use it in GitHub Desktop.
Weird companion object issue in Scala 2.11 vs 2.12
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