What is the meaning and intention of nullable return values from GeometryEngine, such as: GeometryEngine.distanceOrNull
GeometryEngine.projectOrNull
GeometryEngine.clipOrNull
... and so on, there are many methods like this
Does a null return value mean an error occurred, or that input parameters are invalid somehow?
Typically I would expect the api documentation to specify what a null return value means, but I could not find explanations for these, so maybe its some general pattern for this SDK?
Solved! Go to Solution.
Hi @jussih ,
These functions that are suffixed with "OrNull" are lenient functions, following the pattern used in the Kotlin standard library, for example String.toIntOrNull. It means that the function is lenient, i.e. it won't throw an exception if the input is invalid or some other error occurs, instead it returns null.
Does a null return value mean an error occurred, or that input parameters are invalid somehow?
It could be either. As you point out, the doc should specify that, we are going to make some improvements to that. Thank you for pointing it out.
Hi @jussih ,
These functions that are suffixed with "OrNull" are lenient functions, following the pattern used in the Kotlin standard library, for example String.toIntOrNull. It means that the function is lenient, i.e. it won't throw an exception if the input is invalid or some other error occurs, instead it returns null.
Does a null return value mean an error occurred, or that input parameters are invalid somehow?
It could be either. As you point out, the doc should specify that, we are going to make some improvements to that. Thank you for pointing it out.
Thanks for the reply, makes sense.
I was a bit confused though because I assumed calculations like distance and projection would not fail often. Are there some specific things that can go wrong with the parameters or calculation?