2 ms·
> You can work yourself into some weird corners because of how permissive the language is, where in a (strongly) typed language, the complier just says no. Cou
by kab_al_ashraf 6y ago
> You can work yourself into some weird corners because of how permissive the language is, where in a (strongly) typed language, the complier just says no.
Could you share an example?
- blahedo 6y agoHere's one my (intro programming, non-major) students have just been tripping over this week: if word == "this" or "that": ... Not an error, always runs. Very mysterious to a beginner. (Shared with C/C++) Another one: counter = "0" for thing in things: if matches(thing): counter += 1 The error is in the init, by someone who is overzealous with their quoting, but the error is reported, as a runtime error, on the attempted increment, which throws a TypeError and helpfully tells them "must be str, not int", and of course I know exactly why it's reporting the problem there and why it's giving that error, but it's a bit confusing to the newbie programmer and it doesn't even turn up until they actually test their code effectively, which they are also still just learning how to do.
- deleted 6y ago[deleted]