NSScreencast Episode #125 Swift Basics
- swift
- not intended to be replacement of objective-c
- under NDA
- repl
- var x = 30
- no semicolon
- let y = 50
- constants
- var count: Int
- # count: Int: 0
- all variable initialized by default value
- var letter: Character = "A"
- same as string
- var x = 30
- array
- var ids: Int[]
- ids += 1
- ids += [5,6,7]
- ids [1,5,6,7]
- let array => size never change
- constantsでも中の要素は変わる
- not immutable
- var ids: Int[]
- range
- numbers[0..4]
- not include 1,2,3,4
- numbers[0...4]
- include 1,2,3,4,5
- opposite of Ruby
- numbers[0..4]
- Dictionary
- separate by colon
- square bracket
- var gradebook = [ "Al": "A", "Joe": "B", "Charlie": "D" ]
- Dictionary<String, String>
- String?
- if grade { }
- grades += grade
- error: String? not unwrapped
- unwrapp (!)
- grades += grade!
- if let grade =
- without bang!
- loop
- for (student, grade) in gradebook {}
- string interpolation
- " (grade)"