Swift 5.7: Shorthand for optional unwrapping
iOS Software Engineer (Swift, SwiftUI) with +4 years of experience working with international teams and clients, Published +10 apps, seeking to build world-class apps
Search for a command to run...
iOS Software Engineer (Swift, SwiftUI) with +4 years of experience working with international teams and clients, Published +10 apps, seeking to build world-class apps
No comments yet. Be the first to comment.
Sometimes we have to insert items to the first indices of the array The easiest solution can be: var array = [1,2,3,4,5,6,7,8,9] array.insert(0, at: 0) print(array) this solution is going to work, but is it efficient? Looking into the Apple Doc...
Swift 5.7 comes with a new feature that saves our time
To unwrap an optional value we used to do
if let username = username {
print(usernname)
}
After Swift 5.7 new shorthand, we can easily do
if let username {
print(usernname)
}
Without repeating the variable name again
Start using the new shorthand and save your time!