본문 바로가기
[도서 정리] Android Development with Kotlin - Laying a Foundation Android Development with Kotlin - Laying a Foundation 이 정리글은 Kotlin in Action 책을 보고 실무에 Kotlin 을 사용하던 사람이 몰랐던 내용이나 remind 하고 싶은 내용을 위주로 정리한 글입니다.제대로 내용을 파악하시려면 책을 구매해서 읽어보세욤~ -Kotlin type inference 가 생기면서 가끔 무슨 type 으로 inference 가 되었는지 확인하고 싶을 수 있다."expression type” 기능을 사용하면 된다.[View] - [Expression Type] 을 사용하면 된다. ( 혹은 이 녀석을 지정한 단축키 ) 이는 generic type 에 대해서도 잘 작동한다. -var age: Short = 18 과 같이 적절한.. 2018. 12. 11.
[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] Operator overload 와 convention #2 [Kotlin Tutorial] Operator overload 와 convention #2 출처 : Kotlin in action 7.3. Destructuring declarations and component functions -val p = Point(10, 20)val (x, y) = p // destructuringprintln(x)println(y) -destructuring 도 convention 을 사용한다.componentN 이 호출된다. ( N 은 숫자 )val (a, b) = p // val a = p.component1()// val b = p.component2() -data class 는 compiler 가 primaryConstructor 에 정의된 모든 property 에 .. 2017. 8. 29.
[Kotlin Tutorial] Kotlin 기초 #2 - Chap2. Kotlin basics [Kotlin Tutorial] Kotlin 기초 #2 - Chap2. Kotlin basics 참조 : Kotlin in Action 2.4. Iterating over things: "While" and "For" loops -Kotlin 에서 for loop 은 for-each loop 하나밖에 없다. 2.4.1. The “while” loop -Java 와 동일 2.4.2. Iterating over numbers: ranges and progressions -일반적인 for loop 를 쓰려면 range 를 쓰면 된다.Range 는 closed, inclusive 하다 즉 아래의 예에서는 1과 10 모두를 포함한다.val oneToTen = 1..10 -val hundredToOneWithSte.. 2017. 7. 25.
[Kotlin Tutorial] Kotlin 기초 #1 - Chap2. Kotlin basics [Kotlin Tutorial] Kotlin 기초 #1 - Chap2. Kotlin basics 참조 : Kotlin in Action 2.1. Basic elements : Functions and variables 2.1.1. Hello, world! -fun main(args: Array){ println(“Hello, world!”)} fun 는 function 을 정의하는 keywordtype 은 variable 이름 다음에 옴function이 class 정의 안에 있지 않아도 된다Array 가 class 이다 ( Java 는 아니징 ) -> Kotlin 에서는 모든 것이 Object 이다System.out.println 대신 println; (semicolon) 넣을 필요 없다 ( option.. 2017. 7. 25.
[Effective Objective-C] #3 메서드보다는 같은 일을 하는 리터럴 문법을 사용하라 [Effective Objective-C] #3 메서드보다는 같은 일을 하는 리터럴 문법을 사용하라 출처 : Effective Objective-C -NSString, NSNumber, NSArray, NSDictionary 인스턴스 모두 리터럴 문법을 지원한다. -리터럴 문법을 사용하면 소스 코드 크기가 줄고 코드가 읽기 쉬워진다. 리터럴 숫자 -정수, 실수, 불린 값을 Objective-C 로 감쌀(wrapping) 필요가 있다.이는 숫자 타입을 다룰 수 있는 NSNumber 클래스를 이용해 할 수 있다. -리터럴을 쓰지 않으면 다음과 같이 생성한다.NSNumber *number = [NSNumber numberWithInt:1]; 그러나 리터럴을 사용하면 이렇게 간단하다.NSNumber *numbe.. 2017. 7. 20.
Objective-C 의 기본 ( Basic Objective-C ) Object-C 의 기본 ( Basic Objective-C ) 출처 : http://www.tutorialspoint.com/objective_c/ > - OOP 언어로 Smalltalk-style 을 C 언어 에 가미한 언어이다. Apple 의 OSX 와 iOS 에서 공식적으로 사용되는 언어이다. > - Object-C 는 OOP 의 4가지 조건 ( Encapsulation, Data hiding, Inheritance, Polymorphism ) 을 모두 만족시키는 언어이다. - Foundation Framework 는 아래 명시된 기능들을 비롯해 많은 기능을 제공한다. * NSArray, NSDictionary, NSSet 과 같은 data type 을 제공 * file, string 등 많은 u.. 2015. 6. 16.
반응형