2015-11-26 Delay initialization of constant variable in Swift

Last edit

Summary: Recent versions of Swift allow making a variable constant (with the <tt>let</tt> keyword), without directly initializing it. This . . .

Changed:

< let identifier: String
< if flight == self.nextFlight {
< identifier = RosterListActivityCellReuseIdentifier.NextFlight.rawValue
< } else {
< identifier = RosterListActivityCellReuseIdentifier.Flight.rawValue
< }

to

> let identifier: String
> if flight == self.nextFlight {
> identifier = RosterListActivityCellReuseIdentifier.NextFlight.rawValue
> } else {
> identifier = RosterListActivityCellReuseIdentifier.Flight.rawValue
> }


Recent versions of Swift allow making a variable constant (with the let keyword), without directly initializing it.

This makes the following code possible:

	let identifier: String
	if flight == self.nextFlight {
		identifier = RosterListActivityCellReuseIdentifier.NextFlight.rawValue
	} else {
		identifier = RosterListActivityCellReuseIdentifier.Flight.rawValue
	}

Nice!