[swift-users] Cleaner way than if let initialization?

Daniel Tartaglia danielt1263 at gmail.com
Thu Aug 4 12:32:53 CDT 2016


Currently I do stuff like this:

let dobString: String
if let dob = dob {
	dobString = serverDateFormatter.stringFromDate(dob)
}
else {
	dobString = ""
}

Is there a better, more idiomatic, way to do this sort of thing?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160804/2c578b8b/attachment.html>


More information about the swift-users mailing list