https://kotlinlang.org logo
#announcements
Title
# announcements
a

Artem Ohanjanyan

09/10/2017, 6:02 PM
I was confused because I don't have to use inheritance to do that in Java or C++.
k

karelpeeters

09/10/2017, 6:20 PM
You don't really have to do that in Kotlin either?
I just decided to inherit
Iterator
because that's what you asked for.
a

Artem Ohanjanyan

09/10/2017, 6:24 PM
By iterator I meant any kind of pointer to node with public interface.
I just want to be able to store references to LinkedList's nodes without an ability to break it's structure, no need to inherit anything (although it's better to add some interfaces from designer's point of view)
Can you do that without inheritance?
k

karelpeeters

09/10/2017, 6:34 PM
Hmm, you're right, I can't really get something like this to work:
Copy code
class MyClass{
	fun getPublic() = Public(Private()))
	
	private class Private
	
	public class Public(private val node: Node)
}
3 Views