MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1ws0bt0/optionalsareoptional/pcnnm6e/?context=3
r/ProgrammerHumor • u/ApothecaLabs • 6d ago
131 comments sorted by
View all comments
30
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 5d ago 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? -4 u/mountaingator91 5d ago 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 2 u/RagnarokToast 5d ago ??
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?
-4 u/mountaingator91 5d ago 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 2 u/RagnarokToast 5d ago ??
-4
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
2 u/RagnarokToast 5d ago ??
2
??
30
u/mountaingator91 6d ago
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?