Created
January 16, 2018 08:22
-
-
Save xremix/ad460f7cd8378b7de511be69deb71dc5 to your computer and use it in GitHub Desktop.
First not nil Property
This file contains 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
import UIKit | |
class MyObjects: NSObject{ | |
var myOptional: String? | |
var myRequired: String | |
init(req: String, op: String?) { | |
myOptional = op | |
myRequired = req | |
} | |
} | |
var myArray = [MyObjects]() | |
myArray.append(MyObjects(req: "1", op: nil)) | |
myArray.append(MyObjects(req: "2", op: "2")) | |
myArray.append(MyObjects(req: "3", op: nil)) | |
myArray.append(MyObjects(req: "3", op: "3")) | |
let x = myArray.map({return $0.myOptional}).flatMap({$0}).first | |
print(x) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment