can anyone explain this snippet to me? im confused...
# announcements
m
can anyone explain this snippet to me? im confused what exactly happens
k
Extension function on
AquariumPlant
named
pull
, which prints
removing $this
, if instance of
AquariumPlant
, on which
pull
was invoked, was not null
👍 2
m
you sure it's the case of
not null
check?
when i run this code :
Copy code
val nullablePlant: AquariumPlant? = null
nullablePlant.pull()
the
apply()
method isn't invoked
k
Right,
x?.f()
means
if (x != null) x.f()
m
@kr3v you're right, i interpreted it wrong 😅
@karelpeeters thank you for the reference