News for hackers. Stuff that matters.
Re:Yoda Conditions by kazinator on Friday February 17, 2017 @06:53PM (#13672732)
The operator there is let. The = is just a punctuator which indicates the initial value expression for the let.

Litmus test: if this was rendered into S-expressions, the let would stay, but the = would disappear.

Re:Yoda Conditions by nilved on Sunday February 19, 2017 @12:53PM (#13680862)
No, that's just because the example I used was Rust. In Ruby it would be `if user = User.find(..)` and the same goes for Go and plenty of other languages.
Re:Yoda Conditions by kazinator on Sunday February 19, 2017 @10:47PM (#13684125)
If user is being freshly bound, that isn't an assignment but an initialization.

If the construct is not allowed when user is already in scope, it reflects the designer's view that an assignment in a conditional isn't a good thing.

If the construct is allowed when user exists already, with no diagnostic, then it carries the pitfalls that this thread is about.