Lilly
09/19/2022, 11:11 PMLong Int and Byte variables which I use across my codebase but have to convert them to different types. Lets take a Long variable which I have to convert to int (toInt()) or byte (toByte()) at different places. Is it common to provide the same variable as Int or as Byte, e.g. myVariableAsLong, myVariableAsInt, myVariableAsByte? Does this approach make sense, is there another common approach for this case or is it pointless?Joshua Hansen
09/20/2022, 5:12 AMJuliane Lehmann
09/20/2022, 8:07 AMobject Consts {
const val myVarAsInt = 23
val myVarAsByte = myVarAsInt.toByte()
}
So you'd use it as
foo(myVarAsByte)
instead of
foo(myVar.asByte())
I'm not seeing the big advantage there, but if you do, nothing wrong with it. But having a single source of truth is definitely a good idea.Lilly
09/21/2022, 2:07 PMLong data type.Juliane Lehmann
09/21/2022, 2:23 PMLilly
09/21/2022, 2:29 PM