Skip to content

Instantly share code, notes, and snippets.

@nickarthur
Forked from mildocjr/iflet3.swift
Created February 5, 2019 21:49
Show Gist options
  • Select an option

  • Save nickarthur/54e63109930cbb4522b934be1e98ff67 to your computer and use it in GitHub Desktop.

Select an option

Save nickarthur/54e63109930cbb4522b934be1e98ff67 to your computer and use it in GitHub Desktop.
if-let-3
func add(firstPossibleInteger: Int?, secondPossibleInteger: Int?) -> Int? {
guard let firstNumber = firstPossibleInteger,
let secondNumber = secondPossibleNumber
else { return nil } // or 0 if you want to return a
// non-optional value
return (firstNumber + secondNumber)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment