Another random number-related question. When I have a function that accepts a
Number
parameter instead of a more specific type like
Double
or
Int
, can that cause overhead with boxing? Or will the compiler try to avoid that?
d
dmitry.petrov
07/18/2017, 3:21 PM
Yes, it will. Type Number maps to java.lang.Number on JVM, which is an object, of course.
However, if that is an inline function, compiler can potentially optimize boxing out, depending on how the boxed Number value used. Just don't overuse it ;)
👍 1
t
thomasnield
07/19/2017, 1:00 PM
@dmitry.petrov okay cool, thanks. That gives me a lot to play with.