13
Matano
3y

So today I decided to try out Kotlin on Android. Hacked up a little Textview-Button app. AMAZED with the little code.

Comments
  • 1
    Or just...@bind ?
  • 0
    @RazorSh4rk Yea there was @Bind but this is more simpler
  • 1
    I'm new to kotlin and curious, what does the a -> b = c syntax do?
  • 1
    @GlabbichRulz its a kind of arrow function with implicit return
  • 1
    @GlabbichRulz in the when case, its like a case switch, only a lot nicer to use
  • 1
    @nicholai so if "hi" is in the variable hello.text the variable is changed to "click me"? and if not, do nothing in that line? 🤔 don't understand what the following line does then though, looks like it just overwrites to "hi" again
  • 1
    Is the when related to events?
  • 2
    @nicholai aah right, think i got it. Inside the "when" brackets, only one line is executed, as you said similar to a switch case. Thanks!
  • 2
    @GlabbichRulz the when switch stops at the first match and runs that function. In this example the button will toggle text.
  • 1
    @DirtyBit nope, just a betterr switch that can be used as an expression as well, and, well, feels nice for people that are of the functional inclination
  • 1
    @nicholai thanks, even if i wanted to learn kotlin, this would make me reconsider
  • 4
    Ewww light theme
  • 0
    @DirtyBit Not really. The setOnClickListener is the one for event really. We are just using the when() to help in toggling the Textview's text.
  • 0
    @hitchhiker42 LOL. Funny thing is that all my other IDE's, DevRant and text editors are all in dark theme. But for some reason the Dracula theme in IntelliJ has always never been comfortable to my eyes.
Add Comment