

In order to run code in Playground we need to create a main method otherwise, we’ll get a “No main method found in project” error.įor this tutorial, I’ll be using Kotlin v1.7.21 with the JVM compiler. An actions toolbar has also been added that allows you to select the Kotlin version, select the compiler, and set program arguments. Since May 2022, mobile devices are also supported in Playground, so you don’t even need a computer to run Kotlin code. This is very useful if you need to edit multiple lines of code simultaneously: If you hold the Ctrl (Windows) or Command (Mac) key while clicking around, it will create more cursors. There’s also a hidden feature in Kotlin Playground. Just copy the page URL and send it to others or use the “Share code” button to get an embeddable version of the code.

One great feature of Kotlin Playground is that it enables you to easily share the code you wrote with other people. Kotlin Playground comes with all standard Kotlin libraries (collections, reflection, coroutines, etc.) but doesn’t support adding new libraries, meaning you can only use it to prototype or test something that depends on standard Kotlin libraries. It’s developed and maintained by JetBrains. Playground is an editor capable of running Kotlin code and, most importantly, it runs on your browser. What if there was a way to quickly test your ideas? Well, that’s what Kotlin Playground is all about. Sometimes we just want a quick way to test something, but opening Android Studio or another code editor takes some time. Understanding advanced Kotlin coroutines.We’ll also share some advanced coroutines concepts that can be used to simplify asynchronous code. In this article, we’ll demonstrate how to use Kotlin Playground to test your code. If you’ve been working with Kotlin you’ve probably written plenty of tests before, but have you ever tried doing so with Kotlin Playground? Code that’s tested is easier to maintain, and test also often serve as documentation. Testing is an essential part of a developer’s life. Test advanced coroutines with Kotlin Playground Most of his time is spent learning Android and Kotlin, but he also leaves some time for other subjects.

Victor Brandalise Follow Victor is very curious and likes understanding how and why things work this is what drives him to learn new things.
