Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@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
-
@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!
-
nicholai8937y@GlabbichRulz the when switch stops at the first match and runs that function. In this example the button will toggle text.
-
nicholai8937y@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
-
@nicholai thanks, even if i wanted to learn kotlin, this would make me reconsider
-
Matano9947y@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.
-
Matano9947y@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.
Related Rants
So today I decided to try out Kotlin on Android. Hacked up a little Textview-Button app. AMAZED with the little code.
undefined
goodbye findviewbyid
saviour
java
kotlin