One of the most salient features of our Tech Hiring culture is that there is so much bullshit. Everyone knows this. Each of us contributes his share. But we tend to take the situation for granted.
callbackFunction is really a variable, but what kind of value does it accept?
Answer: the value you assign to that variable is a function with a boolean argument.
The basic principle is that, like in Javascript, functions are first-class citizens that you can pass in a parameter of a function or in a variable. To do the same thing In Java, you would have to define a meaning-less interface with one function.
One of the most salient features of our Tech Hiring culture is that there is so much bullshit. Everyone knows this. Each of us contributes his share. But we tend to take the situation for granted.
One of the most salient features of our Tech Hiring culture is that there is so much bullshit. Everyone knows this. Each of us contributes his share. But we tend to take the situation for granted.
Not yet right :)
callbackFunction
is really avariable
, but what kind of value does it accept?Answer: the
value
you assign to that variable is afunction with a boolean argument
.The basic principle is that, like in Javascript, functions are first-class citizens that you can pass in a parameter of a function or in a variable. To do the same thing In Java, you would have to define a meaning-less interface with one function.
You can read the friendly documentation at kotlinlang.org/docs/reference/lamb...
Thanks.. I was actually reading through documentation right now. But your explanation is so much simpler to understand. :)
I also asked this on StackOverflow and your answer along with explanation on internal working from SO, made lambdas so much clear to me.
Glad I could help, don't hesitate asking other #explainmelikeim5 Kotlin questions. I like the exercise of explaining useful things in simple words!
Follow-up:
Send me all the Kotlin questions you were too afraid to ask
Jean-Michel Fayard γ» Oct 6 γ» 1 min read