HelloCW
HelloCW

Reputation: 2295

What does ^map mean in Android Studio 4.0?

The following code is from the project https://github.com/android/databinding-samples.git

What does ^map mean in Android Studio 4.0 ? It seems that I can't delete it and I can't hide it.

Code Image

enter image description here

Upvotes: 1

Views: 85

Answers (2)

Animesh Sahu
Animesh Sahu

Reputation: 8106

That is actually pointing that it is going to be returned to the lambda passed in the map function.

By default the lambda name is same as the function you are calling (map in this case), and by default the lambda returns the last expression that is when in this case. So it will return it to the lambda. you can also explicitly specify that by return@map Popularity.STAR as well.

You can also change the name of the lambda if that bothers you,

Transformations.map(_likes) myLambdaName@ {
        when {
            it > 9 -> Popularity.STAR    // will show as `^myLambdaName`
            it > 4 -> return@myLambdaName Popularity.POPULAR  // explicitly specifying return statement
            else -> Popularity.NORMAL    // will show as `^myLambdaName`
        }
    }

Upvotes: 0

madhead
madhead

Reputation: 33441

It's Lambda return expression hints and you can hide them here in the settings:

enter image description here

Or via a quick action:

enter image description here

Upvotes: 1

Related Questions