thymecypher
12/16/2019, 2:33 AMTim McCormack
12/16/2019, 2:34 AMthymecypher
12/16/2019, 2:34 AMfun hashCode(dataComputed: Int) = dataComputed + myIntArray.sum()
thymecypher
12/16/2019, 2:35 AMarray in data class, consider overriding hashCode
Tim McCormack
12/16/2019, 2:40 AMhellman
12/16/2019, 5:45 AMList
instead?Tim McCormack
12/16/2019, 11:43 AMthymecypher
12/16/2019, 6:24 PMdata
is to reduce boilerplate, and potentially add future optimization, but currently it doesn’t reduce boilerplate, more so that it removes it entirely.
I wouldn’t say it’s necessarily a problem, would just be cool to have additional functionality to extend upon generated functions. It could be part of a greater feature... extend(res: Int) fun hashCode() = res + myArray.sum()
or somethingthymecypher
12/16/2019, 6:33 PMjimn
12/17/2019, 2:28 PMfun arrayOfAnys(it: Array<Any?>): Array<Any?> = deepArray(it) as Array<Any?>
tailrec fun deepArray(inbound: Any?): Any? =
if (inbound is Array<*>) inbound.also {
it.forEachIndexed { i, v ->
(it as Array<Any?>)[i] = deepArray(v)
}
}
else if (inbound is Iterable<*>) deepArray(inbound.map { it })
else inbound
jimn
12/17/2019, 2:39 PM