일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- enum
- 코딩테스트
- interpace
- url
- Method
- Terminal
- IOS
- initalizer
- init
- 스위프트
- Foundation
- delegate
- property
- type
- optional
- 디자인패턴
- Protocol
- Xcode
- initializer
- UIKit
- instance
- Git
- extension
- tuist
- Class
- Swift
- struct
- String
- 이니셜라이저
- Unicode
- Today
- Total
목록Closure (2)
아리의 iOS 탐구생활
Closures — The Swift Programming Language (Swift 5.5) Closures Closures are self-contained blocks of functionality that can be passed around and used in your code. Closures in Swift are similar to blocks in C and Objective-C and to lambdas in other programming languages. Closures can capture and store referen docs.swift.org 클로저(Closure)는 코드의 블록이다. 함수는 ‘이름이 있는 클로저’라고 표현한다. 보통 클로저는 ‘이름이 없는 코드블록’을 ..
let arr = ["leeari", "ari", "lee"] for i in arr { print(i) } arr.forEach { i in print(i) } 두 반복문은 같은 결과물을 출력하지만 차이점이 존재한다. ✔️ 제어문의 영향 for i in arr { if i == "leeari" { continue } if i == "ari" { break } } arr.forEach{ i in // !!! error: only allowed inside a loop !!! // break // continue } for in문은 break과 contiue문을 사용하여 클로저를 탈출할 수 있지만, forEach는 이러한 제어문 사용이 불가능하다. forEach는 내가 반복하고 싶은 구문을 forEach라..