
The main function of the code requires a small refactor in order to be able to receive and process arguments. In the example above, we’re adding the argument Medium.
Last but not least, there’s also a way of adding an argument into the program execution.
JUNIT: JUnit to run test code using regular JUnit annotations like CANVAS: Introduced by HTML5, this platform allows you to draw graphics using JavaScript. JS IR: JavaScript Intermediate Representation is a new way for the Kotlin compiler to parse Kotlin source files. JS: JavaScript for server-side development e.g., Node.js, JQuery, React. JVM: Java Virtual Machine to run Kotlin in the default way. Similarly to the Kotlin version, a couple of clicks will expand the different Target Platform options and change it in order to make your code run differently.īefore moving on, let’s quickly go over the current options present for different Target Platforms: On the right-hand side of the Kotlin version, you can find the Target Platform that your code would be executed on. Simply clicking and choosing a different version will make sure your code is compiled and executed in a different Kotlin version. Starting at the top-left side of the screen, underneath the big Kotlin banner, you can find the Kotlin version that the Playground is currently running on. There are two main editable settings inside the Kotlin Playground. If there are any errors with the execution, the bottom panel will simply hide itself. * You can edit, run, and share this code.Īs soon as the compiler is filled with the code you want to execute, find the “Run” button on the top-right corner of the UI, and wait for the result on the bottom panel. Simply, access and you can start playing around almost immediately! /** Using the Kotlin standard libraries only, the Kotlin Playground can run mildly complex blocks of code directly in your browser without much setup, and without the burdensome matter of ramping up and working with a chunky IDE.
Initially published about 5 years ago, the Kotlin Playground is an online lightweight compiler that allows Kotlin programmers to run code directly in the browser using different versions of Kotlin, and even target different platforms.Īdditionally, the Kotlin Playground gives developers the opportunity to both share their code with other people, as well as embed a small version of the compiler into websites, and particularly into Medium. For these kinds of situations, the lesser-known Kotlin Playground is a great option to try out code on the fly. As a modern Android developer, sometimes I find myself with the need of wanting to run some small snippet of code.