Generic2 [Swift] 제네릭 (Generics) 스위프트 프로그래밍 국내도서 저자 : 야곰 출판 : 한빛미디어 2019.10.01 상세보기 제네릭 (Generics) 함수, 클래스 내부에서 사용할 타입 파라미터를 받아 어떤 타입에도 유연하게 대응하게 작성할 수 있는 스위프트 문법 1. 제네릭 함수 함수명 뒤에 '' 와 같은 방식으로 선언이 가능하다. 이 때 플레이스 홀더의 타입은 전달되는 전달 인자에 의해 결정된다. 전달인자의 타입에 따라서 불필요한 추가 함수들을 만들 필요가 없다. import UIKit func swap(a: inout T, b: inout T) { let temp = a a = b b = temp } var a: Int = 6 var b: Int = 7 print("before a: \(a), b: \(b)") swap(&a, &.. 2021. 5. 28. [자바] Generics 제네릭 Lesson: Generics (Updated) (The Java™ Tutorials > Learning the Java Language) The Java Tutorials have been written for JDK 8. Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available. See JDK Release Notes for information about new fe docs.oracle.com Generics 제네릭 클래스 내부에서 사용할 데이터 타입을 외부에서 임의로 명시할 .. 2020. 9. 3. 이전 1 다음