2 ms·
Splitting = and := is intentional, but not for the reason you stated. We could have used := for all assignments from the beginning: is_logged_in := True o
by selcuka 5mo ago
Splitting = and := is intentional, but not for the reason you stated. We could have used := for all assignments from the beginning:
is_logged_in := True
or
if is_logged_in := True:
I agree that this would require blurring the statement/expression distinction. You can still do that in a weird way, by disguising your assignment as an expression. This is valid:
(is_logged_in := True)
The reason it was done that way because := was an afterthought, and making it the assignment operator would have introduced a breaking incompatibility. That lead to having 3 different symbols for 2 use cases (assignment and comparison).
- Doxin 5mo agoexcept if := was the default then accidentally typing ":=" instead of "==" would be the easy bug to make. := was bolted on after of course, and I think that was a mistake, but no one asked me, nor do I expect anyone to ;P