Created
October 24, 2016 16:26
-
-
Save groz/07cfdd17bb6f843b032385422666e0c4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//: Playground - noun: a place where people can play | |
import UIKit | |
struct Person { | |
let name: Optional<String> | |
let age: Optional<Int> | |
} | |
let tagir: Person = Person(name: "Tagir", age: 32) | |
let alexey: Person = Person(name: "Alexey", age: nil) | |
func isOlder(p1: Person, p2: Person) -> Bool? { | |
return p1.age.flatMap { age1 in | |
p2.age.map { age2 in | |
age1 > age2 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment