Add documentation comment for If let

This commit is contained in:
gprasant 2016-02-19 08:13:46 -08:00
parent 8d6d142e4a
commit 48b2244ac3

View File

@ -94,6 +94,8 @@ var unwrappedString: String! = "Value is expected."
// same as above, but ! is a postfix operator (more syntax candy) // same as above, but ! is a postfix operator (more syntax candy)
var unwrappedString2: ImplicitlyUnwrappedOptional<String> = "Value is expected." var unwrappedString2: ImplicitlyUnwrappedOptional<String> = "Value is expected."
// If let structure -
// If let is a special structure in Swift that allows you to check if an Optional rhs holds a value, and in case it does - unwraps and assigns it to the lhs.
if let someOptionalStringConstant = someOptionalString { if let someOptionalStringConstant = someOptionalString {
// has `Some` value, non-nil // has `Some` value, non-nil
if !someOptionalStringConstant.hasPrefix("ok") { if !someOptionalStringConstant.hasPrefix("ok") {