is it “hacky” to use ::isInitialized?
# getting-started
o
is it “hacky” to use ::isInitialized?
w
We use it... But, everytime I see that code, it looks wrong, looks like I missed something in the architecture of it to not have the need of that.... But, I use that only once, and pushed far, far away in the code (it is a "Wrapper" to a 3rd party library) <-- because of that I decide to "keep" it, if it was in other places and in our business logic classes, probably I will refactor to not need it.
k
I don't think so. It's equivalent to doing a null-check on a nullable variable, but once this one changes, you know that the variable will stay non-null. It's a lot like MonotonicNonNull in Checker (https://checkerframework.org/api/org/checkerframework/checker/nullness/qual/MonotonicNonNull.html)
stronger guarantee than Nullable
k
If you do
::isInitialized
in multiple places imo it's just better to switch to nullable, it's so easy to forget otherwise. If you only check it it one specific place and use the variable normally in many other places I think it's fine.
☝️ 1
o
great, thanks guys