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

코틀린의 데이터 클래스(data class) 에 관해 살펴보자. 원문 https://kotlinlang.org/docs/reference/data-classes.html 을 보며 정리. data 를 저장하기 위한 클래스를 data class 라 하며 data 로 표시한다. data class User(val name: String, val age: Int) 컴파일러가 자동으로 primary constructor 의 properties 로 부터 아래의 멤버들을 생성한다. equals() / hashCode() pair; "User(name=John, age=42)" 폼의 toString(); 선언 순서대로 각 property 에 해당하는 componentN() functions copy() 아래의 요구사항..

코틀린의 클래스의 확장(Extentsion) 에 대해 살펴보자. 원문 https://kotlinlang.org/docs/reference/extensions.html 을 보며 정리. kotlin 의 클래스는 상속이나 디자인 패턴인 Decorator 를 통한 기능 확장 외의 방법인 extention 을 제공한다. 예를들어 수정이 불가능한 third-party 라이브러리의 클래스에 함수를 추가할 수 있다. 마치 원래 클래스에 있는 메소드처럼 함수를 추가해 호출할 수 있게 해주는걸 extension functions 라 한다. property 도 추가할 수 있으며 이를 extension properties 라 한다. Extension functions receiver(확장할 대상) type 과 함수의 이름을 ..

코틀린의 Visibility Modifier 를 살펴보자. 원문 https://kotlinlang.org/docs/reference/visibility-modifiers.html 을 보며 정리. class, object, interface, constructor, function, property 와 그들의 setter 들은 visibility modifier 를 가질 수 있다. visibility modifier : private, protected, internal, public 기본은 public 이다. Packages function, property 와 class, object 와 interface 는 package 내에서 최상위에서 바로 선언할 수 있다. // file name: example..

코틀린의 인터페이스(interface) 에 대해 알아보자. 원문 https://kotlinlang.org/docs/reference/interfaces.html 을 보며 정리. interface 키워드를 사용하는 인터페이스는 추상화 메소드와 그 구현 코드를 가지고 있고 state 는 저장할 수 없다. interface MyInterface { fun bar() fun foo() { // optional body } } Implementing Interfaces 한개의 클래스나 오브젝트는 한개 이상의 인터페이스를 가질 수 있다. class Child : MyInterface { override fun bar() { // body } } Properties in Interfaces 인터페이스는 propert..