Hullaballoonatic
06/07/2019, 9:22 PMfun foo(values: DoubleArray) = //do the things
fun foo(vararg values: Double) = foo(DoubleArray(values.size) { values[it] })
fun foo(values: List<Double>) = foo(values.toDoubleArray())
fun foo(values: Vector) = foo(values.toDoubleArray())
I can use extension methods and chuck many of them into separate files, but sometimes I can't, like in the case of inner classes or objects.
is there a better way that i'm not really seeing? afaik there is absolutely no shared parent class between arrays and lists. my Vector
class at least shares Iterable<Double>
with List<Double>
, but in many cases it's more efficient to duplicate the body of functions the two share instead of unifying them under Iterable
because most methods require Iterable::toList
before I can do foo
things to it.Vector
class implement List<Double>
instead of Iterable<Double>
, but I specifically chose to not do that, because a Vector is not a Listkarelpeeters
06/07/2019, 9:30 PMHullaballoonatic
06/07/2019, 9:31 PMkarelpeeters
06/07/2019, 9:33 PMHullaballoonatic
06/07/2019, 9:33 PMkarelpeeters
06/07/2019, 9:36 PMHullaballoonatic
06/07/2019, 9:38 PM