I hope to see the source code of the fun let
, but I get the following content after I ctrl + click data?.let
.
How to see the source code of a fun in Kotlin in Android Studio 3.1.3?
@kotlin.internal.InlineOnly public inline fun <T, R> T.let(block: (T) -> R): R { /* compiled code */ }
Added Content
And More
The image when I click on choose sources
Solved:
Now it's OK when system updates the Kotlin plugin today.
I think that the system update the plugin failed caused the problem.
How can I update the plugin manually? You know the Update Plugin UI doesn't always be displayed by the system!
From within Android Studio, navigate to Tools -> Android -> SDK Manager. Once open, you'll need to download the Sources for Android SDK as shown below. Once you have the sources downloaded, you can find the source code inside of the "sources" folder of your SDK (wherever that may be on your computer).
To convert Java code to Kotlin, open the Java file in Android Studio, and select Code > Convert Java File to Kotlin File. Alternatively, create a new Kotlin file (File > New > Kotlin File/Class), and then paste your Java code into that file.
Kotlin is an officially supported language for developing Android apps, along with Java.
I can see the source code of let
in kotlin-stdlib-common-1.2.51.jar
where path is kotlin -> Standard.kt (or file name showing as StandardKt.kotlin_metadata)
. I am doing same command.
Below is code of that fun
/**
* Calls the specified function [block] with `this` value as its argument and returns its result.
*/
@kotlin.internal.InlineOnly
public inline fun <T, R> T.let(block: (T) -> R): R {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return block(this)
}
Versions I am using are
Android Studio 3.1.3
Build #AI-173.4819257, built on June 4, 2018
JRE: 1.8.0_152-release-1024-b01 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.12.6
And kotlin version is Version: 1.2.51-release-Studio3.1-1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With