일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- variable
- text
- function
- texttheme
- package
- Flutter
- 다트
- animation
- crawler
- ML
- List
- map
- 플러터
- python
- kotlin
- 코틀린
- 클래스
- Class
- import
- Android
- 크롤러
- set
- pushnamed
- Collection
- 파이썬
- 콜렉션
- textstyle
- 웹크롤러
- DART
- 함수
- Today
- Total
목록kotlin (40)
조용한 담장

코틀린(kotlin) 의 함수 (funciton) 에 대해 살펴보자. 원문 https://kotlinlang.org/docs/reference/functions.html 을 보며 정리. Function declarations 함수 정의는 fun 키워드를 사용한다. fun double(x: Int): Int { return 2 * x } Function usage 함수 호출 val result = double(2) 멤버 함수 호출 Stream().read() // create instance of class Stream and call read() Parameters 함수 파라미터는 Pascal notation 을 써서 정의한다. 각 파라미터는 type 이 정의되어야 한다. fun powerOf(numbe..

코틀린(kotlin) 클래스의 위임(delegation) 을 살펴보자. 원문 https://kotlinlang.org/docs/reference/delegation.html 을 보며 정리. Implementation by Delegation kotlin 은 상속의 대안이 되는 Delegation pattern 을 boilerplate code 없이 지원한다. 아래 예제에서, Derived 클래스는 자신의 모든 public 멤버들을 특정 오브젝트(BaseImpl)로 위임하여 Base 인터페이스를 구현할 수 있다. interface Base { fun print() } class BaseImpl(val x: Int) : Base { override fun print() { print(x) } } class ..

코틀린 클래스의 Object Expressions and Declarations 를 살펴보자 원문 https://kotlinlang.org/docs/reference/object-declarations.html 을 보며 정리. 새로운 클래스를 만들지 않고 특정 클래스에 약간의 수정만 한 오브젝트를 만드는 방법에 대해 살펴본다. Object expressions 특정 type 을 상속한 익명(이름없는) 클래스(anonymous class) 의 오브젝트를 생성하는 방법 window.addMouseListener(object : MouseAdapter() { override fun mouseClicked(e: MouseEvent) { /*...*/ } override fun mouseEntered(e: Mou..

코틀린 클래스의 제네릭(generic) 에 대해 알아보자. 원문 https://kotlinlang.org/docs/reference/generics.html 을 보며 정리. 코틀린의 제네릭 클래스: class Box(t: T) { var value = t } T 는 type parameter 이다. 클래스의 인스턴스를 생성할 때 type argument 를 제공해야 한다. val box: Box = Box(1) 생성자의 인자 값을 통해서나 다른 어떤 방식이든 parameter 의 타입이 추론이 가능할 때는 type argument 의 생략이 가능하다. val box = Box(1) // 1 has type Int, so the compiler figures out that we are talking ab..