Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- CustomView
- hilt
- LiveData
- notification
- recyclerview
- CoordinatorLayout
- 알고리즘
- CollapsingToolbarLayout
- onLayout
- Coroutine
- Android
- 알림
- DataBinding
- room
- 안드로이드
- BOJ
- HTTP
- Behavior
- AppBarLayout
- ViewModel
- activity
- Algorithm
- sqlite
- lifecycle
- Navigation
- 백준
- onMeasure
- 코틀린
- kotlin
- View
Archives
- Today
- Total
목록연산자 오버라이딩 (1)
개발일지
Kotlin in A..Z (24) - 연산자 오버라이딩
연산자 오버라이딩 operator 키워드를 통해 구현한다. 코드 class Base(var x: Int = 0) { operator fun plus(other: Base): Base { return Base(this.x + other.x) } override fun toString(): String { return "Base(x = $x)" } } fun main() { val x = Base(1) val y = Base(2) println(x + y) } 결과 Base(x = 3) 연산자 종류 표현식 의미 a + b a.plus(b) a - b a.minus(b) a * b a.times(b) a / b a.div(b) a % b a.rem(b) a..b a.rangeTo(b) a(b) a.invoke..
Kotlin (코틀린)
2020. 7. 18. 02:37