How to use the new isEmpty command in Swift
As developers, we sometimes have to check and see if an array, set, string, or other collection types are nil.
In the past, you might write code like this:
let name = “”
if name.count = 0
{
print(“You did not give a name”)
}
But, with the new isEmpty statement, one can write the above like this:
let name = “”
if name.isEmpty
{
print(“You did not give a name)
}
Using the above statement makes development faster and easier to read and understand.