Skip to content

Instantly share code, notes, and snippets.

@madeleine-chercover-hs
Last active December 14, 2017 23:22
Show Gist options
  • Save madeleine-chercover-hs/df25901c702d2ff75cb4cd859462478c to your computer and use it in GitHub Desktop.
Save madeleine-chercover-hs/df25901c702d2ff75cb4cd859462478c to your computer and use it in GitHub Desktop.
def validateLatLong(latitude: Double, longitude: Double): Option[(Double, Double)] =
if (latitude < -90 || latitude > 90 || longitude < -180 || longitude > 180)
None
else
Some((latitude, longitude))
val foo =
validateLatLong(49, 123) match {
case Some((latitude, longitude)) => /* Proceed with validated data */
case None => /* Handle case where no value is returned */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment