본문 바로가기
Swift15 - Nil-Coalescing Operator Nil-Coalescing Operator The nil-coalescing operator (a ?? b) unwraps an optional a if it contains a value, or returns a default value b if a is nil. The expression a is always of an optional type. The expression b must match the type that is stored inside a. nil 병합 연산자란 - Optional ?? Value - 옵셔널 값이 nil이 아니면 해당 값 반환, 옵셔널 값이 nil이면 오른쪽 값 반환 var optionalVal1: String? = nil var optionalVal2: String? .. 2021. 2. 3.
Swift14 - Optional Chaining Optional Chaining Optional chaining is a process for querying and calling properties, methods, and subscripts on an optional that might currently be nil. If the optional contains a value, the property, method, or subscript call succeeds; if the optional is nil, the property, method, or subscript call returns nil. Multiple queries can be chained together, and the entire chain fails gracefully if .. 2021. 2. 3.
Swift13 - Initialization & Deinitialization Initialization Initialization is the process of preparing an instance of a class, structure, or enumeration for use. This process involves setting an initial value for each stored property on that instance and performing any other setup or initialization that is required before the new instance is ready for use. Setting Initial Values for Stored Properties Classes and structures must set all of .. 2021. 2. 2.
Swift12 - 상속 Inheritance A class can inherit methods, properties, and other characteristics from another class. When one class inherits from another, the inheriting class is known as a subclass, and the class it inherits from is known as its superclass. 스위프트 상속 - 클래스, 프로토콜은 상속이 가능하지만 열거형, 구조체는 상속이 불가능 - 스위프트의 클래스는 단일상속으로, 다중상속을 지원하지 않습니다. - final 키워드를 사용하면 재정의(override)를 방지할 수 있습니다. - static 키워드를 사용해 타입 메서드를.. 2021. 2. 2.
Swift11 - 프로퍼티 Properties Properties associate values with a particular class, structure, or enumeration. Stored properties store constant and variable values as part of an instance, whereas computed properties calculate (rather than store) a value. Computed properties are provided by classes, structures, and enumerations. Stored properties are provided only by classes and structures. 프로퍼티란 - 저장 프로퍼티는 구조체, 클래스.. 2021. 2. 2.
Swift10 - first class citizen 1급객체란? - 컴퓨터 프로그래밍 언어 디자인에서, 일급 객체란 다른 객체들에 일반적으로 적용 가능한 연산을 모두 지원하는 객체를 가리킨다. - 보통 함수에 매개변수로 넘기기, 수정하기, 변수에 대입하기와 같은 연산을 지원할 때 일급 객체라고 한다. - 일급객체는 무슨 혜택을 받는다는 게 아니라, 사용할 때 다른 요소들과 아무런 차별이 없다는 것을 뜻한다. - 정수와 실수처럼 가장 간단한 스칼라 자료형은 대부분 일급 객체이다. - 스위프트에서는 클로저를 통해 일급함수를 구현 일급 객체와 이급 객체. ALGOL에서 실수는 표현식에 사용하거나 변수에 할당할 수 있으며, 프로시저에 매개변수로 넘겨질 수 있다. 하지만 프로시저의 경우 프로시저 콜에서 호출 대상 혹은 매개 변수로 등장할 수 있을 뿐이며, 프로시저.. 2021. 2. 2.