Hey guys, I tried to read this block of code (from...
# announcements
o
Hey guys, I tried to read this block of code (from kotlin docs) a few times but I can't understand 3 things. 1. Red part- why is there a semicolon there? 2. Blue part - how is the
parent
which is a
Person
type can just call the
children
variable as like this list is a part of it? 3. I am also not sure how a
Person
instance is passed to the constructor of a class which is
Person
Source: https://kotlinlang.org/docs/reference/classes.html
k
1. mistake in the example 2.
children
is a member of
Person
and
parent
is a
Person
o
Ohh got it Thanks @kevinherron What about 3? (I just edited the question)
k
it’s not a very well thought out example, don’t overthink it
the point is to show you that secondary constructors exist and what the syntax is
👍 2
o
lol this completely fu*** up my mind
thank you 🙂
d
I think if you change
class Person {
to
class Person() {
it will make sense.
p
@Dico how does that makes a difference?
k
@pavi2410 because then you could build a
Person
without needing a
Person
to seed it (which would need
Person
, which would need a
Person
...)