bbaldino
02/10/2020, 5:05 PMNonZeroInt. I can do something like throw in plus, minus, etc. if the result ends up being 0...but how can I prevent the instance from being initialized with 0? I can't do an init block to verify it, and have to expose the primary constructor. I tried looking at UInt, which prevents you from assigning a negative number to it, but how does it enforce that? The primary constructor takes in an Int.Mike
02/10/2020, 5:10 PMbbaldino
02/10/2020, 5:14 PMUInt is able to restrict the assignment?todd.ginsberg
02/10/2020, 5:38 PMprintln((-3).toUInt())
// 4294967293bbaldino
02/10/2020, 5:39 PMval x: UInt = -10todd.ginsberg
02/10/2020, 5:39 PM-10 is an Int. Change it to 10 and you get the same complaint. It's complaining about the type, not its range.bbaldino
02/10/2020, 5:40 PMbbaldino
02/10/2020, 5:40 PM10 the same way)todd.ginsberg
02/10/2020, 5:41 PMbbaldino
02/10/2020, 5:42 PMtodd.ginsberg
02/10/2020, 5:43 PMbbaldino
02/10/2020, 5:44 PM-3 in `UInt`'s case), and want to make sure it's "corrected" when it's accessedbbaldino
02/10/2020, 5:45 PMUInt being in a separate package and marking the wrapped value as internal prevents that from happening in its casebbaldino
02/10/2020, 5:45 PMvalue directlybbaldino
02/10/2020, 5:55 PMUInt only gets away with an internal constructor by doing
@Suppress("NON_PUBLIC_PRIMARY_CONSTRUCTOR_OF_INLINE_CLASS")
but it is seeming like hiding the internals of an inline class and making sure it's constructed properly can be necessarybbaldino
02/10/2020, 5:56 PMFleshgrinder
02/11/2020, 5:54 AM