Hullaballoonatic
06/21/2019, 7:55 PMUnit
? I'm not a huge fan of Void
, but I'd just as soon prefer Blah
Hullaballoonatic
06/21/2019, 7:57 PMRobert Menke
06/21/2019, 8:00 PMUnit
seems just as reasonable as any other choice to me. It’s a unit of work that doesn’t give you anything back.Hullaballoonatic
06/21/2019, 8:01 PMHullaballoonatic
06/21/2019, 8:01 PMUnit
Robert Menke
06/21/2019, 8:03 PMvoid
can be pretty easily overloaded… unless your were making some game that had an object called “Void”. That would get messy 😛.Hullaballoonatic
06/21/2019, 8:03 PMHullaballoonatic
06/21/2019, 8:04 PMRuckus
06/21/2019, 8:08 PM()
. Kotlin, being very explicit, decided to call the unit, well, Unit
.Ruckus
06/21/2019, 8:14 PMvoid
is a bit vague. It doesn't differentiate between a useless value (the unit type) and no value (called "divergent" when dealing with function returns). Kotlin does using Unit
and Nothing
, so you can specify a function that returns (albeit without useful info) and a function that never returns.Hullaballoonatic
06/21/2019, 8:16 PMNothing
. I think only when I leave in TODO()
Ruckus
06/21/2019, 8:18 PMTODO()
and error()
. However, it's really powerful when used with generics (thanks to Kotlin's sweet usage of variance). So if you ever use emptyList()
, it actually underneath returns a List<Nothing>
that can be safely cast to any type.Ruckus
06/21/2019, 8:19 PMEither
Hullaballoonatic
06/21/2019, 8:19 PMEither
what the heck?Ruckus
06/21/2019, 8:20 PMHullaballoonatic
06/21/2019, 8:22 PM|
?Ruckus
06/21/2019, 8:23 PMsealed class Either<T, U> { ... }
class Left<T>(val value: T) : Either<T, Nothing> { ... }
class Right<T>(val value: T) : Either<Nothing, T> { ... }
Ruckus
06/21/2019, 8:23 PMHullaballoonatic
06/21/2019, 8:23 PMRuckus
06/21/2019, 8:23 PMHullaballoonatic
06/21/2019, 8:26 PMHullaballoonatic
06/21/2019, 8:27 PMRuckus
06/21/2019, 8:28 PMHullaballoonatic
06/21/2019, 8:29 PMHullaballoonatic
06/21/2019, 8:29 PMRuckus
06/21/2019, 8:30 PMHullaballoonatic
06/21/2019, 8:36 PMOption
for so long. i've never gotten around to writing the class myselfRuckus
06/21/2019, 8:41 PMNone
is just object : Option<Nothing>
Hullaballoonatic
06/21/2019, 9:14 PMEither
Hullaballoonatic
06/21/2019, 9:15 PMRuckus
06/21/2019, 9:20 PMEither
means it either one or the other, not both, so calling Ether<Int, String>.subString(1)
doesn't actually make sense. You first need to check if it is Left
or Right
.Hullaballoonatic
06/21/2019, 9:21 PMepabst
06/22/2019, 1:53 PMRobert Menke
06/22/2019, 1:57 PM