본문 바로가기
[도서 목차 정리] Kotlin in action [도서 목차 정리] Kotlin in action Kotlin in action 을 공부하면서 정리한 내용입니다.Java 를 어느 정도 이해하고 숙달한 사람들이 이해하기 좋습니다.Java 와 동일하거나 너무 당연한 기본적인 내용은 정리하지 않았습니다. Kotlin 소개 - Kotlin : what and why Kotlin 기초 #1 - Chap2. Kotlin basics Kotlin 기초 #2 - Chap2. Kotlin basics 함수 정의하고 호출하기 #1 - Chap 3. Defining and calling functions 함수 정의하고 호출하기 #2 클래스, objects, 그리고 인터페이스 #1 - Chap4. Classes, objects, and interfaces 클래스, obje.. 2017. 9. 25.
[Kotlin Tutorial] Operator overload 와 convention #1 - Chap7. Operator overloading and other conventions [Kotlin Tutorial] Operator overload 와 convention #1 - Chap7. Operator overloading and other conventions 참조 : Kotlin in action -Java 에는 특정 class 에 결속되어 있는 언어적 기능이 있다.예를 들어 Iterable 를 구현하면 for loop 에서 쓸 수 있고, AutoCloseable 을 구현하면 try-with-resources 에서 사용할 수 있다. Kotlin 도 비슷한 것들이 있다.그러나 specific type 에 결속된 것이 아니라 specific name 에 결속되는 기능들이 있다.예를 들어 plus 라는 이름으로 class 에 function 을 추가하면, + operator 를 해.. 2017. 8. 24.
[Kotlin Tutorial] Kotlin 의 Type system - Chap6. The Kotlin type system [Kotlin Tutorial] Kotlin 의 Type system - Chap6. The Kotlin type system 출처 : Kotlin in action 6.1. Nullability 6.1.1. Nullable types -Kotlin 은 nullable types 를 지원한다.nullable type 이라는 것은 어떤 variable 이 null 을 가질 수 있는지를 명시하는 것이다. -nullable 하지 않은 곳에 null 을 넣으면 compile error 가 난다.기본 type 은 nullable 하지 않으며, nullable 을 만드려면 type 뒤에 ? 를 붙여주면 된다.어떤 타입이든 뒤에 ? 를 붙여줄 수 있다.fun strLenSafe(s: String?) = … 6.1.2.. 2017. 8. 18.
[Kotlin Tutorial] 람다로 프로그래밍 하기 - Chap5. Programming with Lambdas [Kotlin Tutorial] 람다로 프로그래밍 하기 - Chap5. Programming with Lambdas 참조 : Kotlin in Action 5.1. Lambda expressions and member references 5.1.1. Introduction to lambdas : blocks of code as function parameters 5.1.2. Lambdas and collections -val people = listOf(Person(“Alice”, 29), Person(“Bob”, 31))println( people.maxBy{ it.age } ) // function 을 argument 로 받는다. { } 는 lambda syntax lambda 가 단순 functio.. 2017. 8. 16.
[Kotlin Tutorial] 클래스, objects, 그리고 인터페이스 #2 [Kotlin Tutorial] 클래스, objects, 그리고 인터페이스 #2 참조 : Kotlin in Action 4.3. Compiler-generated methods: Data classes and Class delegation 4.3.1. Universal object methods -Java 에서 == 는 primitive 나 object 의 reference 를 비교하는 것.Kotlin 에서는 == 가 기본비교이다. equals 를 호출해서 비교한다.그럼 Java 에서의 == 는? === 로 대체된다. 4.3.2. Data classes: autogenerated implementations of universal methods -data class Client(val name: Stri.. 2017. 8. 14.
[Kotlin Tutorial] 클래스, objects, 그리고 인터페이스 #1 - Chap4. Classes, objects, and interfaces [Kotlin Tutorial] 클래스, objects, 그리고 인터페이스 #1 - Chap4. Classes, objects, and interfaces 참조 : Kotlin in Action 4.1. Defining class hierarchies 4.1.1. Interface in Kotlin -Kotlin 의 interface 는 Java8 과 비슷하다.abstract method 를 가질수도 있고, Java8의 default method 도 가질 수 있다. ( Java8 과는 다르게 default keyword 는 필요없다 )단, state 는 여전히 가질 수 없다. ( 실제 variable ) -Kotlin 에서 interface 정의는 아래와 같다.interface Clickable{ fun.. 2017. 8. 11.
[Kotlin Tutorial] 함수 정의하고 호출하기 #2 [Kotlin Tutorial] 함수 정의하고 호출하기 #2 참조 : Kotlin in Action 3.4. Working with collections: Varargs, Infix calls, and Library support 3.4.1. Extending the Java collections API -val strings: List = listOf(“first”, “second”, “thrid”)strings.last() val numbers: Collection = setOf(1, 14, 2)numbers.max() last 와 max 는 extension 이다.이 외에도 많이 있으니 IDE 의 code completion 을 잘 활용해보시라~ 3.4.2. Varargs: functions tha.. 2017. 8. 3.
[Kotlin Tutorial] 함수 정의하고 호출하기 #1 - Chap 3. Defining and calling functions [Kotlin Tutorial] 함수 정의하고 호출하기 #1 - Chap 3. Defining and calling functions 참조 : Kotlin in Action 3.1. Creating collections in Kotlin -아래와 같이 쉽게 collection 을 만들 수 있다."type”Of 의 form 이다.val hashSet = hashSetOf(1, 7, 53) // mutableval set = setOf(“Gamza”, “Goguma”) // immutable val list = arrayListOf(1, 7, 53) // mutable val map = hashMapOf(1 to “one”, 7 to “seven”, 53 to “fifty-three”) // mutable/.. 2017. 8. 3.
반응형