Simplify getDestinationFromRoute

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
Harsh Shandilya 2021-02-10 18:03:56 +05:30
parent 703957e2b7
commit 98866ee407
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80

View file

@ -20,13 +20,7 @@ enum class Destination(
val startDestination = Hottest val startDestination = Hottest
fun getDestinationFromRoute(route: String): Destination { fun getDestinationFromRoute(route: String): Destination {
values().forEach { return values().firstOrNull { it.route == route } ?: error("Incorrect route password")
if (it.route == route) {
return it
}
}
throw IllegalStateException("Incorrect route passed")
} }
} }
} }