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 |
Tags
- 단위테스트
- microservice architecture
- spring cloud
- test
- spring cloud netflix zuul
- forkandjoinpool #threadpool #jvm #async #non-blocking
- reactive
- api-gateway
- Eureka
- Dynamic Routing
- 탐색
- code refactoring
- zuul
- spring cloud netflix
- netflix
- unit
- java #jvm #reference #gc #strong reference
- springcloud
- unittest
- dfs
- 설계
- Spring Data Redis
- Java
- netflix eureka
- BFS
- container image #docker #layer #filesystem #content addressable
- 서비스스펙
- docker
- spring cloud netflix eureka
Archives
- Today
- Total
phantasmicmeans 기술 블로그
10. Kotlin - Functional Interface 본문
Functional (SAM) Interface
- SAM: Single Abstract Method
자바에서도 마찬가지로 하나의 abstract method를 가지는 인터페이스를 functional interface라 하고 코틀린도 마찬가지이다.
functional interface 를 선언하려면 fun
modifier를 사용하면 된다.
fun interface KRunnable {
fun invoke()
}
SAM Conversions
이것도 자바와 동일하게 람다식을 활용하면 된다. 자바 Functional Interface를 알고 있다면 아주 쉽게 이해 될 것이다.
functional interface
fun interface IntPredicate {
fun accept(i: Int): Boolean
}
not sam conversion
val isEven = object: IntPredicate {
override fun accept(i: Int): Boolean {
return i % 2 == 0
}
}
sam conversion
val isEven = IntPredicate { it % 2 == 0 }
더 자세한 사항: https://www.baeldung.com/kotlin/lambda-expressions
'Programming > Kotlin' 카테고리의 다른 글
12. Kotlin - Extension Function VS Function literal with receiver (0) | 2021.01.22 |
---|---|
11. Kotlin - Higher Order Functions (0) | 2021.01.22 |
9. Kotlin - Interface (0) | 2021.01.22 |
8. Kotlin - Backing Field (0) | 2021.01.22 |
7. Kotlin - Properties (0) | 2021.01.22 |
Comments