2 ms·
But that's just poor coding practices as you're letting any old garbage in as data without first validating it (and that's assuming such data was user generated
by laumars 14y ago
But that's just poor coding practices as you're letting any old garbage in as data without first validating it (and that's assuming such data was user generated. If the garbage was generated within your code itself then you have even bigger problems).
Don't get me wrong, I'm not against loosely typed languages (eg in Perl it's very handy being able to use strings and integers as booleans), but that example you've given would scare me in any language as you shouldn't be making any assumptions about data unless the program generated that data itself (and even then, I'd still run a few checks if just to catch unconsidered exceptions / security vulnerabilities)
- justincormack 14y agoNot necessarily, the initialiser should do validation, and can still throw...