Kotlin – Addition on Generic

New to kotlin so I apologize if this question is silly. In scala I was able to define addition and subtraction between generic numeric types. I could write a single function that added two numbers together whether I passed in doubles, ints, etc.

Is there any way to mimic this functionality in Kotlin? I find it hard to believe my best bet is writing separate functions for each or some huge when statement.

For what it’s worth, I know the parameters be from a field, which kmath has an interface for, but I’m not sure this really helps me here.

submitted by /u/Either-Consequence-6
[link] [comments]