Enable a parameter to accept more than one type as input, while being more focused than using "Any"
I have a method that takes in value which must be of type Boolean, Float, Int, Long, or String. Is there a way make this method only accept those types for value, rather than take in Any and handle incorrect values, like I've done with with the when() statement?
fun putValue(key: String, value: Any) {
when (value) {
is Boolean -> putBoolean(key, value)
is Float -> putFloat(key, value)
is Int -> putInt(key, value)
is Long ->...