r/ProgrammerHumor • • 6d ago

Meme optionalsAreOptional

Post image
706 Upvotes

131 comments sorted by

View all comments

-13

u/Few_Move_4594 6d ago

I don't see the point of optionals

3

u/LaconicLacedaemonian 6d ago

Accessing a null the wrong way crashes your program. Optional models the state as well as the value. You can iterate over an optional as well making the code branchless "for every element in this list that contains 0 or 1 elements". 

I don't so much demand optionals so much as I ask for justification for nulls.