This file contains hidden or 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
func printString(aString: String) { | |
print("Printing the string passed in: \(aString)") | |
} | |
printString("Hi, my name is Thanh") | |
let someFunction: String -> Void = printString | |
someFunction("Hi, look at me!") | |
/*****************/ |
This file contains hidden or 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 ReadItLaterClient { | |
lazy var session: NSURLSession = NSURLSession(configuration: NSURLSessionConfiguration.defaultSessionConfiguration()) | |
/* Do the rest of the work */ | |
} |
This file contains hidden or 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
//: Playground - noun: a place where people can play | |
import UIKit | |
enum ReadingMode { | |
case Day | |
case Evening | |
case Night | |
var statusBarStyle: UIStatusBarStyle { |
This file contains hidden or 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 | |
//struct Rectangle { | |
// var length: Int | |
// var width: Int | |
// | |
// var area: Int { | |
// return length * width | |
// } | |
//} |
This file contains hidden or 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 | |
struct Point { | |
let x: Int | |
let y: Int | |
} | |
struct Map { | |
static let origin: Point = Point(x: 0, y: 0) |
This file contains hidden or 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
protocol Printable { | |
func description() -> String | |
} | |
protocol PrettyPrintable: Printable { | |
func prettyDescription() -> String | |
} | |
struct User: PrettyPrintable { | |
let name: String |
This file contains hidden or 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
protocol FullyNameable { | |
var fullName: String { get } | |
} | |
struct User: FullyNameable { | |
var fullName: String | |
} | |
let user = User(fullName: "John Smith") |
This file contains hidden or 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
enum Coin: Double { | |
case Penny = 0.01 | |
case Nickel = 0.05 | |
case Dime = 0.1 | |
case Quarter = 0.25 | |
} | |
let wallet: [Coin] = [.Penny, .Nickel, .Dime, .Dime, .Quarter, .Quarter, .Quarter] | |
var count: Int = 0 |
This file contains hidden or 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
class Address { | |
var streetName: String? | |
var buildingNumber: String? | |
var apartmentNumber: String? | |
} | |
class Residence { | |
var address: Address? | |
} |
This file contains hidden or 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
class Point { | |
var x: Int | |
var y: Int | |
init(x: Int, y: Int){ | |
self.x = x | |
self.y = y | |
} | |
} |