Hi everybody! I just watched the super interesting talk by @simon.vergauwen and would like to bring something up regarding the Idiomatic API name consistency. It might've already been discussed and isn't actually that important but anyway here it is:
Some of the Either functions follow the right/left convention: Either.onRight(), Either.onLeft(). However, the counterpart to Either.leftOrNull is Either.getOrNull. In order to be consistent shouldn't it be named Either.rightOrNull? Or alternatively: Either.errorOrNull/Either.getOrNull. What do you think?
s
simon.vergauwen
04/13/2023, 1:33 PM
Hey @Jose,
Interesting that you bring this up. A week or two before the release I compared to the Kotlin Result type and it follows the pattern you’re seeing on this slide.
Which is
getOrNull
and
exceptionOrNull
. The
get
implies happy path or success value.
j
Jose
04/13/2023, 1:49 PM
Given that semantically Either works with left and right, and having leftOrNull I thought it would make sense to have rightOrNull as well.
In any case it's nothing important and I understand your reasoning of naming it after Kotlin's Result.
BTW, congrats on your talk 👏
s
simon.vergauwen
04/13/2023, 1:51 PM
Thank you ☺️ And thank you for the feedback. I think following the same pattern of Kotlin Std makes most sense since it should feel most natural.