Created
October 23, 2019 19:45
-
-
Save jimmya/ad1e60ffe4ffdee5be950b76965d6f5a to your computer and use it in GitHub Desktop.
Using Array+Extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import Utilities | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
let names = ["John", "Mary", "Joe"] | |
let name = names[safe: 2] // Optional: "Joe" | |
let anotherName = names[safe: 5] // nil | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment