Skip to content

Instantly share code, notes, and snippets.

@iamthiago
Last active June 23, 2017 01:44
Show Gist options
  • Save iamthiago/604e6b5ecf9ab6de51697f2fb7e90e34 to your computer and use it in GitHub Desktop.
Save iamthiago/604e6b5ecf9ab6de51697f2fb7e90e34 to your computer and use it in GitHub Desktop.
case class Address(state: Option[String], city: Option[String], neighborhood: Option[String], street: Option[String], streetNumber: Option[String]) {
def toMap(): Map[String, String] = {
Map(
"state" -> this.state,
"city" -> this.city,
"neighborhood" -> this.neighborhood,
"street" -> this.street,
"streetNumber" -> this.streetNumber
).filter(_._2.isDefined).mapValues(_.get)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment