본문 바로가기
[도서 목차 정리] 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] The Kotlin ecosystem [Kotlin Tutorial] The Kotlin ecosystem 참조 : Kotlin in action -비록 Kotlin 의 역사는 오래되지 않았지만, 이미 lib, framework, tool 들로 구성된 ecosystem 이 잘 마련되었다.그리고 그들은 대부분 외부 개발 커뮤니티에서 개발된 것이다. https://kotlin.link/ 여기 가면 많은 정보를 얻을 수 있다. -Kotlin 은 Java 와 함께 사용가능하기 떄문에,lib 검색할 떄 Kotlin lib 으로 한정지을 필요가 없다. 당연히 Java lib 을 가져다 써도 된다. 1. Testing -JUnit, TestNG 도 좋지만, 아래 DSL 들은 더 표현력이 풍부하다. KotlinTest https://github.com/k.. 2017. 9. 22.
[Kotlin Tutorial] Documenting Kotlin code [Kotlin Tutorial] Documenting Kotlin code 출처 : Kotlin in action 1. Writing Kotlin documentation comments -Java 의 Javadoc 만들 때와 비슷하다.Kotlin 의 것은 KDoc 이라 부른다. -KDoc 은 /** 로 시작하고 tag 는 마찬가지로 @ 로 시작한다.Javadoc 과의 가장 큰 차이가 있다면 HTML 대신 Markdown 을 사용한다는 것이다./** * Calculates the sum of two numbers, [a] and [b] */fun sum(a: Int, b: Int) = a+b 정의를 참조하려면 [ ] 안에 이름을 넣어주면 된다. cf) Markdown 은 text-to-HTML conve.. 2017. 9. 20.
[Kotlin Tutorial] Annotation 과 Reflection #2 [Kotlin Tutorial] Annotation 과 Reflection #2 참조 : Kotlin in action 10.2. Reflection: introspecting Kotlin objects at runtime -Kotlin 에서의 reflection 은 java.lang.reflect package 의 API 들과 kotlin.reflect package 의 API 들을 사용한다.Kotlin 의 reflection 은 Java 에 없는 nullable type 이나 properties 들의 접근을 가능하게 한다. -runtime lib 의 size 를 줄이기 위해, kotlin 의 reflection API 는 kotlin-reflect.jar 라는 별개의 jar 로 pakcage 되어 있.. 2017. 9. 12.
[Kotlin Tutorial] Annotation 과 Reflection #1 - Chap 10. Annotations and reflection [Kotlin Tutorial] Annotation 과 Reflection #1 - Chap 10. Annotations and reflection 참조 : Kotlin in action 10.1. Declaring and applying annotations. 10.1.1. Applying annotations -Annotation 사용법은 Java 와 동일하다. @ 를 prefix 로 하고 annotation name 을 써주면 된다. -@Deprecated 의 경우 Kotlin 은 Java 의 것에서 향상되었다.replaceWith parameter 가 추가되어, 새로운 version 의 API 에 연결될 수 있다.@Deprecated(“Use removeAt(index) instead.”, Rep.. 2017. 9. 7.
[Kotlin Tutorial] Generics - Chap9. Generics 참조 : Kotlin in action 9.1. Generic type parameters -Java 와 기본적으로 generic 사용법은 동일하다. -Type Inference 는 가능하지만 명시적으로 써야 하는 케이스도 있다.val authors = listOf(“Dmitry”, “Svetlana”) // type inference 가능 val readers : MutableList = mutableListOf() // type inference 불가능, 명시적 선언val readers = mutableListOf() -Kotlin 에서는 raw type generic 을 사용할 수 없다. ( Java 로 치자면 그냥 List ) 9.1.1. Generic functions and properties.. 2017. 9. 5.
[Kotlin Tutorial] 한 차원 높은 함수 : 람다를 parameter 와 return value 로 - Chap8. Higher-order functions: lambdas as parameters and return values [Kotlin Tutorial] 한 차원 높은 함수 : 람다를 parameter 와 return value 로 - Chap8. Higher-order functions: lambdas as parameters and return values 참조 : Kotlin in action 8.1. Declaring higher-order functions -Higher-order function 이란 argument 와 return 으로 다른 function 을 갖는 것을 의미한다.Kotlin 에서는 function 이 lambda 나 function reference 로 표시된다. 8.1.1. Function types -val sum = { x:Int, y:Int -> x+y }val action = { pr.. 2017. 8. 31.
[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 #2 [Kotlin Tutorial] Kotlin 의 Type system #2 참조 : Kotlin in action 6.2. Primitive and other basic types 6.2.1. Primitive types: Int, Boolean, and more -Kotlin 은 primitive type 과 wrapper type 을 구분하지 않는다. -그렇다면 Int 가 object 라면 Kotlin 은 모든 primitive type 을 실제로 object 로 만드는가?당연히 그렇게 안 했다.compiler 가 대부분의 Int type 을 Java 의 primitive type 으로 변형시킨다.generic, collection 등은 원래 Java 의 Integer 형태만 담을 수 있으므로 이 경.. 2017. 8. 22.
반응형