can anybody please explain the meaning of the stat...
# announcements
j
can anybody please explain the meaning of the statement, val image = +imageResource(R.drawable.header) what is the use of "+" sign and hwy to use it?
d
It's a use of operator overloading, in this case the
unaryPlus
operator. https://kotlinlang.org/docs/reference/operator-overloading.html
j
If i remove + operator here what will be its significance? val image = imageResource(R.drawable.header)
d
The first one is equivalent to this:
val image = imageResource(R.drawable.header).unaryPlus()
The 2nd is just:
val image = imageResource(R.drawable.header)
j
yes i am asking the same what makes val image = imageResource(R.drawable.header).unaryPlus() difference from val image = imageResource(R.drawable.header) ?
d
The first calls
unaryPlus
, the 2nd doesn't...? I am not sure what your question is.
d
probably the question is what unaryPlus() is doing
which you can look at the source
j
yes
m
you have to find where the operator overload is defined
j
okay
d
Yo should be able to ctrl-click on the "+" sign like on a normal method call and Intellij should take you there
j
i got it
g
Looks like #compose
😅 2