Swift notes

1. To create an empty array or dictionary, use the initializer syntax.

let emptyArray = [String]()
let emptyDictionary = [String: Float]()

2. Use the init?(rawValue:) initializer to make an instance of an enumeration from a raw value. It returns either the enumeration case matching the raw value or nil if there is no matching Rank.

3. f let convertedRank = Rank(rawValue: 3) {
let threeDescription = convertedRank.simpleDescription()
}

4. One of the most important differences between structures and classes is that structures are always copied when they are passed around in your code, but classes are passed by reference.

5. Classes, enumerations, and structs can all adopt protocols.

6. Writing is the same as writing … where T: Equatable.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s