Shawn
02/05/2019, 4:27 PMonEach
I think?Shawn
02/05/2019, 4:27 PMStrum355
02/05/2019, 4:29 PMskennedy
02/05/2019, 7:43 PMsealed
is as close you can get to thatMarc Knaup
02/05/2019, 7:43 PMDominaezzz
02/05/2019, 7:44 PMskennedy
02/05/2019, 7:45 PMdiesieben07
02/05/2019, 8:01 PMMarc Knaup
02/05/2019, 8:02 PMinternal
constructor is a good idea actually 🤔Marc Knaup
02/05/2019, 8:02 PMMarc Knaup
02/05/2019, 8:02 PMAlexey Subbota
04/12/2019, 4:24 PMtapchicoma
04/12/2019, 5:44 PM1.3.30
version 🙂gaetan
04/12/2019, 9:45 PMRobert
04/13/2019, 8:13 PM1L and 1
, but CAN'T I use 1 and 1L
? Can I somehow globally add the infix myself (i tried, but it has to be in the same package or something)? Like this inline infix fun Int.and(long: Long) = this.toLong() and long
Hullaballoonatic
04/13/2019, 10:18 PMclass Foo<T : Bar = Baz>
Hullaballoonatic
04/13/2019, 10:38 PMval (id, *contents) = line.split(",").map { it.trim() }
Hullaballoonatic
04/14/2019, 3:26 AMHullaballoonatic
04/14/2019, 3:28 AMSmallville7123
04/14/2019, 5:15 PMType mismatch: inferred type is T#2 (type parameter of preprocessor.utils.core.algorithms.LinkedList)? but T#1 (type parameter of preprocessor.utils.core.algorithms.LinkedList.LinkedListIterator)? was expected
Smallville7123
04/14/2019, 5:16 PMinner class LinkedListIterator<T>() {
var node = head
fun hasNext(): Boolean {
if (node != null) {
if (node?.next != null) return true
}
return false
}
fun next(): T? {
if (node != null) {
if (node?.next != null) {
return node?.value
}
}
node = node?.next
return null
}
}
fun iterator() : LinkedListIterator<T> = LinkedListIterator()
karelpeeters
04/14/2019, 5:53 PM<T>
, and your inner class is shadowing that one. You probably don't want an independent one for the inner class, so remove that.Smallville7123
04/15/2019, 2:55 AMSmallville7123
04/15/2019, 4:33 AMclass A, forEach
or somethingSmallville7123
04/15/2019, 4:34 AM.iterator
aswell then override it in the classSmallville7123
04/15/2019, 4:36 AMclass A, iterator, forEach {
override fun iterator() = LinkedListIterator()
}
or somethingAlowaniak
04/15/2019, 5:50 AMAlowaniak
04/15/2019, 5:54 AMfun Iterable.foo()
...)
However in case of forEach
I'm relatively sure there is one on Iterable alreadySmallville7123
04/15/2019, 6:16 AMSmallville7123
04/15/2019, 6:20 AMclass LinkedList<T> : kotlin.collections.Iterable<T> {
object i : kotlin.collections.Iterator<T> {
override fun hasNext(): Boolean {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun next(): T {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}
override fun iterator(): kotlin.collections.Iterator<T> {
return i
}
/home/macropreprocessor/IdeaProjects/kpp/src/linuxMain/kotlin/preprocessor/utils/core/algorithms/LinkedList.kt: (5, 44): Unresolved reference: T
for object i : kotlin.collections.Iterator<T> {