You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Swift 5.9 introduced the final implementation of of SE-0380.
It is now possible to rewrite a given ternary operator using if/swift expressions
let value = 5
result = value != 0 ? x : y
turns into
let value = 5
result = if value != 0 {
x
} else {
y
}
In my opinion this syntax can lead to a more readable result than using a ternary operator making it more useful for evaluating complex conditions and expands the complexity of conditions that are evaluated during assignment. It might be a good idea to mention it or include additional language describing best practices.
The text was updated successfully, but these errors were encountered:
Swift 5.9 introduced the final implementation of of SE-0380.
It is now possible to rewrite a given ternary operator using if/swift expressions
turns into
In my opinion this syntax can lead to a more readable result than using a ternary operator making it more useful for evaluating complex conditions and expands the complexity of conditions that are evaluated during assignment. It might be a good idea to mention it or include additional language describing best practices.
The text was updated successfully, but these errors were encountered: