▲ | bobertlo a day ago | |
Would you rather have undefined initial values? | ||
▲ | optician_owl a day ago | parent [-] | |
I would. Not because it's something pleasant. There is a huge difference between no value and default value. I had plenty cases where I needed to distinguish them because absent value is a violation of a contract. Defaults are not a solution. And more. Defaults bring their own problem. Chosen values are neutral only for some operations. The most simplest case - int default value is 0, but it kinda "works" only for sums. With nulls you'll get an error in production. With defaults discovery of the error is postponed even more. It's literally the same as making up values ignoring clients will (and this decision even not ours but designers of the lang). Defaults are implicit. It's simplifies mistakes due to human factor. |