News for hackers. Stuff that matters.
Re:Show HN: Zero-dependency Java framework out of beta by kaba0 on Monday September 25, 2023 @04:14PM (#37649950)
I have never ever ever seen a null inside an Optional -- the most common constructor actually Optional::ofNullable makes the correct decision, so you can't even fck it up, and if you deliberately try to, I'm sure intellij would scream your head off.
Re:Show HN: Zero-dependency Java framework out of beta by jen20 on Monday September 25, 2023 @04:19PM (#37650015)
The problem is whether the optional itself is null, not whether the contained value is.
Re:Show HN: Zero-dependency Java framework out of beta by kaba0 on Monday September 25, 2023 @04:22PM (#37650062)
That’s not a problem either.
Re:Show HN: Zero-dependency Java framework out of beta by waynesonfire on Saturday September 30, 2023 @12:37PM (#37717110)
The reason you've never seen it is because it won't let you,

private Optional(T value) { this.value = Objects.requireNonNull(value); }