4 ms·
Same thing with Python and PHP.
by workhere-io 13y ago
Same thing with Python and PHP.
- lugg 13y agoAm I the only one who doesn't see a huge problem with this? Its actually kinda handy sometimes to have the last value / index of your array defined outside after the loop. Same goes for variables defined within the loop. Aside from that: Function scope makes sense to me but I dont think I've ever gone and thought "damn it all, if only I had block scope!"
- workhere-io 13y agoAm I the only one who doesn't see a huge problem with this? I don't think anyone really sees a problem with it, although it might be somewhat of a gotcha for people coming from languages where variables are local to the loop.
- lugg 13y agoAnd it doing the opposite would be a gotcha for anyone else. Is anyone able to explain why a language would have block scoping in the first place? Is it a good thing and I just don't know? I really hope its not because of the braces.. That would be kind of silly. As it is, without that explanation, all I can think is, so weird language x does something weird and then its a gotcha when a language (funnily enough javascript) does it in a non weird way? I'd say sounds more like a gotcha for language x, than anything else.