Brian Dilley
09/10/2020, 6:43 PMvoid
LeoColman
09/10/2020, 7:02 PMVoid
LeoColman
09/10/2020, 7:03 PMShawn
09/10/2020, 7:04 PMUnit
isn’t exactly like `void`—a void method doesn’t return anything at all, where a method that has a return type of Unit
does return Unit
, even if implicitlyShawn
09/10/2020, 7:05 PMvoid
is more akin to Kotlin’s Nothing
Shawn
09/10/2020, 7:05 PMUnit
. It’s a real object
, you can reference it as a value, even write extension methods for it if you wantedBrian Dilley
09/10/2020, 7:06 PMSkaldebane
09/10/2020, 8:43 PMUnit
is basically the object with only one value... It's a "unit", it can't change or hold multiple values. And yes, it is the void
counterpart for Java. If you don't need or care about what a function returns, preferably use Unit
as the return type.Nir
09/10/2020, 9:45 PMNir
09/10/2020, 9:45 PMUnit
is a monostate typeNir
09/10/2020, 9:45 PMNir
09/10/2020, 10:29 PMNir
09/10/2020, 10:29 PM