|
|
|
|
|
by wycy
2144 days ago
|
|
Assignments in conditionals can be handy handy, but I think it's better when there's a keyword for it. The Rust/Swift `if let` syntax is pretty nice for this. if let userID = 0 {}
vs if userID == 0 {}
The let syntax makes this error more obvious. |
|
(This difference in the behavior of the assignment operator is a result of Rust's ownership semantics; since assignment transfers ownership, having the assignment operator evaluate to the assigned value would actually result in the original assignment being entirely undone!)