4 ms·
In Python you can't have "if x = 3:" ... that's a syntax error. And Python also uses "==" for equality comparison. There, problem solved. I would solve the pr
by bad_user 16y ago
In Python you can't have "if x = 3:" ... that's a syntax error. And Python also uses "==" for equality comparison.
There, problem solved.
I would solve the problem in Obj-C by introducing a directive on the file-level for the newer syntax, like how they did it in F# with the "#light" directive. And when a file is compiled with that directive, the compiler could trigger compile-time errors for those obviously dangerous constructs.
- silversmith 16y agoI'd like to provide a counter-example here: Ruby allows this construct, enabling me to write x = Post.first ? do_foo(x) : do_bar # does the assignment, then evaluates the result A nice shorthand in my opinion, so the python way isn't a cure-all :)
- troystribling 16y agoI think you mean this (x = Post.first) ? do_foo(x) : do_bar