<Can I restrict a generic function to be called wi...
# stackoverflow
u
Can I restrict a generic function to be called with primitive types and Strings only? I have a function that assembles a URL with GET parameters, and it takes a parameter name of type String and currently a parameter value of type Any? on which it calls toString() if not null. I want it to work only for types which can be meaningfully put into a URL (numbers, strings and booleans), and prevent people from calling it with any other object type. Is this possible in Kotlin? The usecase is that I tend to forget converting units to numbers when calling this function, and end up...