Jannis
01/08/2019, 7:26 PMnfrankel
01/08/2019, 9:14 PMBob Glamm
01/08/2019, 9:15 PMBob Glamm
01/08/2019, 9:16 PMnfrankel
01/08/2019, 9:16 PMnfrankel
01/08/2019, 9:16 PMOption<T>
is not null
Bob Glamm
01/08/2019, 9:17 PMOption<T>?
- and you can't tell me that T can't be null, because I can show you ways it can beBob Glamm
01/08/2019, 9:19 PMOption<T>
(or T
) is null the code has bigger problemsnfrankel
01/08/2019, 9:19 PMOption<T>
vs T
optionals vs non-nullable types
so if you’ve got both, fine with me 👍nfrankel
01/08/2019, 9:20 PMIfthat is not an argument...(orOption<T>
) is null the code has bigger problemsT
Bob Glamm
01/08/2019, 9:20 PMnfrankel
01/08/2019, 9:20 PMBob Glamm
01/08/2019, 9:21 PMBob Glamm
01/08/2019, 9:21 PMJannis
01/08/2019, 9:21 PMnfrankel
01/08/2019, 9:21 PMJannis
01/08/2019, 9:22 PMnfrankel
01/08/2019, 9:22 PMOption<T>
in java is worth nothing
because it can be null
itselfnfrankel
01/08/2019, 9:23 PMOption<T>
and Option<T>?
it does the jobJannis
01/08/2019, 9:23 PMnfrankel
01/08/2019, 9:25 PMJannis
01/08/2019, 9:26 PMJannis
01/08/2019, 9:33 PMBob Glamm
01/08/2019, 9:38 PMKind<F,A>
syntax but Scala doesn't do much better in that regardJannis
01/08/2019, 9:39 PMBob Glamm
01/08/2019, 9:39 PMBob Glamm
01/08/2019, 9:39 PMnfrankel
01/08/2019, 10:01 PMJannis
01/08/2019, 10:04 PMnfrankel
01/08/2019, 10:07 PMghedeon
01/10/2019, 4:47 AMOptional<T>
nonsense, I highly recommend you first 15min of Rich Hickey's talk (author of Clojure): . Where he compares optionals in Clojure, Haskell and Kotlin and calls introducing Maybe/Either
to Clojure his billion dollar mistake, because it's a language hack and not a true union. He also mentions that Kotlin got it right.Jannis
01/10/2019, 8:50 AMghedeon
01/10/2019, 9:47 AMBob Glamm
01/10/2019, 12:57 PMBob Glamm
01/10/2019, 1:11 PMT?
and Option<T>
. Both represent a universe of values of T
plus the non-existent value of that type. The difference comes in the expressiveness of the type: with T?
I'm doomed to forever write if (t != null)
in order to use it - and I'm stuck with manually converting that value to something else if I need that value in a different container. Option<T>
at least gives me combinators and transformational functions to easily interact with other applicative/monadic types.Bob Glamm
01/10/2019, 1:14 PM*?
(maybe Any
?) to provide me with the same combinators/transformational functions that are on Option<T>
. Unfortunately I am not aware of any lightweight mechanism in Kotlin to efficiently provide those extension methods on every single nullable type - including types provided by other JVM languages.Bob Glamm
01/10/2019, 1:21 PMOption<T>
is far less noisy to write code with than T?
IME