Skip to content

Instantly share code, notes, and snippets.

point =
{ x = 1, y = 5 }
point2 =
{ point | x = 21 }
var sum = 0
ints.filter { it > 0 }.forEach {
sum += it
}
square = lambda x: x**2
func filter<T>(arr: [T], predicate: T -> Bool) -> [T]
String constructionFirm = person?.residence?.address?.constructionFirm;
val firm: String? = personOption?.residence?.address?.constructionFirm
let firm: String? = personOption?.residence?.address?.constructionFirm
let firm: Optional<String> = personOption
.flatMap { $0.residence }
.flatMap { $0.address }
.map { $0.constructionFirm }
val firm = for {
person <- personOption
residence <- person.residence
address <- residence.address
} yield address.constructionFirm
val firm = personOption
.flatMap(_.residence)
.flatMap(_.address)
.map(_.constructionFirm)