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

Jay M

11/28/2019, 11:03 AM
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

diesieben07

11/28/2019, 11:05 AM
It's a use of operator overloading, in this case the
unaryPlus
operator. https://kotlinlang.org/docs/reference/operator-overloading.html
j

Jay M

11/28/2019, 11:07 AM
If i remove + operator here what will be its significance? val image = imageResource(R.drawable.header)
d

diesieben07

11/28/2019, 11:07 AM
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

Jay M

11/28/2019, 11:08 AM
yes i am asking the same what makes val image = imageResource(R.drawable.header).unaryPlus() difference from val image = imageResource(R.drawable.header) ?
d

diesieben07

11/28/2019, 11:09 AM
The first calls
unaryPlus
, the 2nd doesn't...? I am not sure what your question is.
d

Dias

11/28/2019, 11:16 AM
probably the question is what unaryPlus() is doing
which you can look at the source
j

Jay M

11/28/2019, 11:16 AM
yes
m

Matteo Mirk

11/28/2019, 11:30 AM
you have to find where the operator overload is defined
j

Jay M

11/28/2019, 11:30 AM
okay
d

diesieben07

11/28/2019, 11:31 AM
Yo should be able to ctrl-click on the "+" sign like on a normal method call and Intellij should take you there
j

Jay M

11/28/2019, 11:31 AM
i got it
g

gildor

11/28/2019, 1:04 PM
Looks like #compose
😅 2