+ 2
Questions about Kotlin
In this kotlin code, when we write map{it.toInt()} what is "map" and what is "it"? why is it also valid to write map{String :: toInt} ? ALSO, here we are able to assign values using userinput to 3 variables together using val (x, y, z) what is this feature called? is it available in java as well? https://code.sololearn.com/cTGNdP6IDs5d/?ref=app
15 odpowiedzi
+ 7
When we use function types we may also provide names for parameters, this further improves clarity of code:
val sin: (angleInRadians: Double) -> Double = Math::sin
Math::sin // method reference
this is equivalent to { x -> Math.sin(x) }
Function references in Kotlin: use functions as lambdas everywhere
https://antonioleiva.com/function-references-kotlin/
Reference to a function
::happyNewYear // function reference
happyNewYear( x ) // function call
https://try.kotlinlang.org/#/Examples/Callable%20references/Reference%20to%20a%20function/Reference%20to%20a%20function.kt
+ 9
Asirap Practice time! 😄💪😁👍
Function references in Kotlin:
use functions as lambdas everywhere
https://code.sololearn.com/cEVm894IJ93R/?ref=app
+ 7
A beginner's guide to Kotlin
https://blog.bugsnag.com/introduction-to-kotlin/
+ 6
https://code.sololearn.com/c02Vi9dPdVk4/?ref=app
https://code.sololearn.com/c2ho07cgv097/?ref=app
+ 6
Asirap 👍I'm glad,
I knew you would understand, because I'm learning this way too! 🤓
It's not a problem, you can freely use everything you need, the codes are written to make it easier for us.💪
I have more useful codes, but when I find them, I'll let you know.
Have a nice Coding my friend! ;)🍻
+ 2
Basic tutorial about lambda, also by Danijel:
https://code.sololearn.com/WNtO9vg0wvxE/?ref=app
Best resource for learning Kotlin: Tutorial published by Danijel 👍👍👏👏🌄🌅🎆🎇🎆🎉🎊🎊
A catalog is here:
https://code.sololearn.com/WKFF4vOCr3mi/?ref=app
+ 2
Assigning multiple values in one statement like you showed is called destructuring. It's not possible to do it in Java, unfortunately.
+ 1
thank you Danijel Ivanović . I did not know about lambdas in programming before, it's hard to wrap my head around it. What's the -> thing?
Also can you please recommend any resources that would give me a very basic idea about lambdas and all?
+ 1
thank you! can you please explain the difference between map{it.toInt()}
and map{String::toInt} and how they do the same thing?
Danijel Ivanović Gordon
+ 1
Danijel Ivanović I've understood what -> is finally! thank you for making the codes. i've made a web code where I've included links to some of your codes as reference hope that's okay. Also can you kindly also explain my question in the comments about String::toInt please?
+ 1
thank you so much again! this is going to help me learn kotlin better and faster! Danijel Ivanović
+ 1
Danijel Ivanović saved to my kotlin list
https://code.sololearn.com/WISXv8tPWjPL/?ref=app
+ 1
LunarCoffee thank you! no one else answered that part of my question :D