I\'m trying to put an exception for the following line:
let someData Int = Int(anArray[0])!
I want the exception so that it ignores it if its a
You missed the proper solution:
if let someData = Int(anArray[0]) {
// someData is a valid Int
}
Or you can use guard
:
guard let someData = Int(anArray[0]) else {
return // not valid
}
// Use someData here
Note the complete lack of the use of !
. Don't force-unwrap optionals unless you know it can't fail.