C와 Python 베이스인 사람 입장에서 Swift 언어에서 새로 등장하는 개념 혹은 키워드를 정리해보았습니다. https://bbiguduk.gitbook.io/swift 해당 공식문서 번역 Gitbook에 키워드에 대한 설명이 나와있습니다.
a ?? bfor index in 1...5 {문자열 다루는 거 볼때 다시 보야야할 듯
String은 Foundation프레임워크의 NSString이 bridge된 타입이기 때문에 NSStringString에서 캐스팅 없이 사용 가능 -> 뒤에 dict도 마찬가지isEmpty 프로퍼티를 이용String은 값 타입(value type).var name = 'cozy'
var newname = name
name = 'noasdaq'
newname
// 'cozy'let multiplier = 3
\(Double(multiplier) * 2.5)
// 7.5startIndex, endIndex , index(before:), index(after:), index(_:offsetBy:)var welcome = 'hello'
welcome[1]
// errorvar someInts = [Int]()[] 괄호에 표현fallthrougth: 이후의 case 에 대해서도 실행labelName: while condition {
statements
}label 이름과 while 조건을 넣어 특정 구문을 실행하는 구문으로 사용guard: 특정 조건을 만족하지 않으면 이 후 코드를 실행하지 않도록 방어코드를 작성if #available(iOS 10, macOS 10.12, *) {
//
} else {
//
}func greet(person: String, from hometown: String) -> String {func someFunction(_ firstParameterName: Int, secondParameterName: Int) { → someFunction(1, secondParameterName: 2)func arithmeticMean(_ numbers: Double...) -> Double {func swapTwoInts(_ a: inout Int, _ b: inout Int) {