Hi, is it possible to create a `when` statement dy...
# announcements
a
Hi, is it possible to create a
when
statement dynamically from a map, or two arrays/lists? something like
Copy code
val teamMap : Map<String, String> = mapOf("Yankees" to "baseball", "Cowboys" to "football", "Lakers" to "basketball")
val sport : String = when {
  teamMap.map { e -> mystring.contains(e.key) -> e.value }
}
also a value for
else
would need to be supplied, not sure the best way
e
You don’t need a when statement, you can just do it like this:
a
thanks Evan. terrific. I had started with a manual
when
statement so didn't even think of accessing the map directly