DEV Community

Discussion on: Why using Yoda conditions you should probably not be

Collapse
 
palle profile image
Palle

Or languages designed with code safety in mind, which prohibit these kinds of expressions.

For example in Swift (and other type safe programming languages), the following expression results in a compile time error:

if name = "Luke Skywalker" { // error: use of '=' in a boolean context, did you mean '=='?
    // ...
}
Collapse
 
greg0ire profile image
Grégoire Paris

Woah! Neat!