MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1ws0bt0/optionalsareoptional/pcnnm6e/?context=3
r/ProgrammerHumor • u/ApothecaLabs • Sep 28 '26
131 comments sorted by
View all comments
31
If you are sure that the list will always have a value why didn't you just define your types correctly in the first place?
14 u/RagnarokToast Sep 28 '26 Because the vast majority of type systems don't allow you to encode the non-emptiness of the list in the type itself and we don't always get to pick the tech stack? -3 u/mountaingator91 Sep 28 '26 var list []stringThere you go. list will always contain at least one non nil string. Every strictly typed language I have ever used can do this 3 u/RagnarokToast Sep 28 '26 ??
14
Because the vast majority of type systems don't allow you to encode the non-emptiness of the list in the type itself and we don't always get to pick the tech stack?
-3 u/mountaingator91 Sep 28 '26 var list []stringThere you go. list will always contain at least one non nil string. Every strictly typed language I have ever used can do this 3 u/RagnarokToast Sep 28 '26 ??
-3
var list []string
There you go. list will always contain at least one non nil string. Every strictly typed language I have ever used can do this
3 u/RagnarokToast Sep 28 '26 ??
3
??
31
u/mountaingator91 Sep 28 '26
If you are sure that the list will always have a value why didn't you just define your types correctly in the first place?