chiroptical
12/08/2022, 2:01 AMT?
. In Haskell, I use the maybe function pretty frequently. The type is like (default: U, f: (T) -> U, x: T?): U
chiroptical
12/08/2022, 2:02 AMnullableThing.maybe(default) { x -> … }
chiroptical
12/08/2022, 2:03 AMnullableThing?.let { x -> …} ?: default
which would be the body of the extension function. So, I guess I have two questions: how do I write the extension function and is this really the only way to implement this function?chiroptical
12/08/2022, 2:03 AMephemient
12/08/2022, 2:30 AMchiroptical
12/08/2022, 2:47 AMPablichjenkov
12/08/2022, 2:49 AMPablichjenkov
12/08/2022, 2:50 AMchiroptical
12/08/2022, 2:51 AM?.letWithDefault
chiroptical
12/08/2022, 2:51 AMchiroptical
12/08/2022, 2:52 AMPablichjenkov
12/08/2022, 2:53 AMPablichjenkov
12/08/2022, 2:54 AM.letAndApplyOrDefault()
perhapschiroptical
12/08/2022, 2:54 AMPablichjenkov
12/08/2022, 2:55 AMchiroptical
12/08/2022, 2:55 AMmaybe
but that is just how I am used to it being called.Pablichjenkov
12/08/2022, 2:56 AMPablichjenkov
12/08/2022, 2:56 AMchiroptical
12/08/2022, 3:32 AMmapOr
isn’t badmkrussel
12/08/2022, 1:29 PMletWith
is broken if R
is nullable and block
returns null.chiroptical
12/08/2022, 2:10 PM