Skip to content

Tag: kotlin

RxJava Live Reactive Queue (with on off switch)

Working on an android app in kotlin. I need to set up a system to be able to do work from a live queue (and observe the results of the work in a stream). But I also have to be able to toggle the “queue processing” depending on a couple external factors (which also come in as streams) like networkI…

Convert indefinitely running Runnable from java to kotlin

I have some code like this in java that monitors a certain file: This is my kotlin code: I dont understand what Runnable I should pass into mHandler.postDelayed. What is the right solution? Another interesting thing is that the kotlin to java convertor freezes when I feed this code. Answer Lambda-expressions …

What is the `it` in Kotlin lambda body?

For example in these two following codes: and In this code what does it mean? Answer it variable is an implicit parameter in lambda. One other helpful convention is that if a function literal has only one parameter, its declaration may be omitted (along with the ->), and its name will be it:

Difference between a class and object in Kotlin

I’m new to Kotlin and have recently converted a simple file from java to Kotlin. I am wondering why the Android converter changed my java class to a Kotlin object. Java: Converted Kotlin: Why wasn’t it: Any help would be greatly appreciated thanks. Answer A Kotlin object is like a class that can&#…

How can I run Kotlin-Script (.kts) files from within Kotlin/Java?

I noticed that IntelliJ can parse .kts files as Kotlin and the code editor picks them up as free-floating Kotlin files. You are also able to run the script in IntelliJ as you would a Kotlin file with a main method. The script executes from top to bottom. This form is PERFECT for the project I’m working …