I'd like to be able to write a function that accepts mutiple parameters but only of a certain types. Let's say that String and Int are allowed but not Double:
foo("a", 1) // compiles foo("b", 2.0) // won't compile, doubles are not allowed
In Scala, I would define implicits for each valid type, these implicits would convert to MyObject and my function would simply accept MyObject parameters.
I can’t come up with a way to do this in Kotlin. The first step seems to be to define extension functions on String and Int, but past this, I’m stuck.
Is there a way that I’m no seeing? Such a feature would go a long way toward making DSL’s less clutterered…