1

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

assylias
  • 321,522
  • 82
  • 660
  • 783
HelloCW
  • 843
  • 22
  • 125
  • 310
  • 3
    That's just the return statement of map function, meaning that this statement is the result of map function – Mohammad Sianaki Jun 24 '20 at 05:51
  • 1
    Does this answer your question? [What are the \`^let\` annotations in Android Studio / IntelliJ?](https://stackoverflow.com/questions/48395318/what-are-the-let-annotations-in-android-studio-intellij) – madhead Jun 24 '20 at 11:36

2 Answers2

1

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

madhead
  • 31,729
  • 16
  • 153
  • 201
0

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`
        }
    }
Animesh Sahu
  • 7,445
  • 2
  • 21
  • 49