DEV Community

Discussion on: My favorite ❤️ Swift extensions

Collapse
 
hoangvu23108 profile image
Ken Lâm

I think you missed something here

let array = [0, 1, 2]
if let item = array[safe: 5] {
    print("unreachable")
}

It should be

let array = [0, 1, 2]
if let item = array[safe: 5] {
    print(item)
} else {
    print("unreachable")
}