-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Description
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.
insha
Metadata
Metadata
Assignees
Labels
No labels