notes/pl/kt/features/operator-overload.txt
Ihar Hancharenka 7e564072a5 m
2025-08-06 16:27:53 +03:00

30 строки
1.2 KiB
Plaintext

https://kotlinlang.org/docs/reference/operator-overloading.html
invoke
https://www.baeldung.com/kotlin/operator-overloading
https://www.kotlinprimer.com/classes-what-kotlin-brings-to-the-table/miscellaneous/operators/#d05e
https://stackoverflow.com/questions/45173677/invoke-operator-operator-overloading-in-kotlin
https://stackoverflow.com/questions/54045644/how-does-kotlin-dispatch-the-invoke-operator
https://kotlinlang.org/spec/operator-overloading.html
https://kotlinlang.org/docs/operator-overloading.html
2023
https://medium.com/@dugguRK/mastery-on-invoke-kotlin-8f1ebb4828d0
2019
https://blog.frankel.ch/kotlin-operators/
2018
http://thetechstack.net/blog/2018/12/15/kotlin-operators
operator fun ArchiveInputStream.iterator() = object : Iterator<ArchiveEntry> {
// This line eagerly pulls the first element from the stream when the iterator is created.
// You may have to do something in next() if this doesn't work for you.
var next: ArchiveEntry? = getNextEntry()
override operator fun hasNext() = next != null
override operator fun next(): ArchiveEntry {
val tmp = next ?: throw NoSuchElementException()
next = getNextEntry()
return tmp
}
}