Giter Site home page Giter Site logo

jetbrains / kotlin-playground Goto Github PK

View Code? Open in Web Editor NEW
430.0 38.0 78.0 2.65 MB

Self-contained component to embed in websites for running Kotlin code

Home Page: https://jetbrains.github.io/kotlin-playground/examples/

License: Apache License 2.0

JavaScript 60.74% SCSS 8.95% TypeScript 30.06% HTML 0.19% Shell 0.06%
kotlin kotlin-playground playground

kotlin-playground's Introduction

official JetBrains project NPM version

Kotlin Playground

Component that creates Kotlin-aware editors capable of running code from HTML block elements.

Examples

Installation

Use our CDN

Insert a <script> element into your page and specify what elements should be converted in its data-selector attribute.

<script src="https://unpkg.com/kotlin-playground@1" data-selector="code"></script>

Or, if you need to separate process of loading/conversion, omit the data-selector attribute and use a second <script> element like this:

<script src="https://unpkg.com/kotlin-playground@1"></script>

<script>
document.addEventListener('DOMContentLoaded', function() {
  KotlinPlayground('.code-blocks-selector');
});
</script>

You can also overwrite the server where the code will be sent to be compiled and analyzed (for example if you host a server instance that includes your own Kotlin libraries). For that you can set the data-server attribute.

And you can also set a default Kotlin version for code snippets to run on. Bear in mind that the version set per editor will take precedence though:

<script src="https://unpkg.com/kotlin-playground@1"
        data-selector="code"
        data-server="https://my-kotlin-playground-server"
        data-version="1.3.41">
</script>

Fork & clone the old server repository or the new server.

Host your own instance

Install Kotlin-playground as dependency via NPM.

npm install kotlin-playground -S

And then just use it in your code.

// ES5
var playground = require('kotlin-playground');

document.addEventListener('DOMContentLoaded', function() {
  playground('code'); // attach to all <code> elements
});


// ES6
import playground from 'kotlin-playground';

document.addEventListener('DOMContentLoaded', () => {
  playground('code'); // attach to all <code> elements
});

Use from plugins

  1. Kotlin Playground WordPress pluginWordPress plugin which allows to embed interactive Kotlin playground to any post.
  2. Kotlin Playground Coursera plugin — Allows embedding interactive Kotlin playground for coursera lessons.
  3. Kotlin Playground Orchid plugin — Allows embedding interactive Kotlin playground in Orchid documentation sites.

Options

Kotlin Playground supports several events, and also Kotlin version or server URL overwriting passing an additional options parameter on initialisation.

For example:

function onChange(code) {
  console.log("Editor code was changed:\n" + code);
}

function onTestPassed() {
   console.log("Tests passed!");
}

const options = {
  server: 'https://my-kotlin-playground-server',
  version: '1.3.50',
  onChange: onChange,
  onTestPassed: onTestPassed,
  callback: callback(targetNode, mountNode)
};

playground('.selector', options)

Events description:

  • onChange(code) — Fires every time the content of the editor is changed. Debounce time: 0.5s. code — current playground code.

  • onTestPassed — Is called after all tests passed. Use for target platform junit.

  • onTestFailed — Is called after all tests failed. Use for target platform junit.

  • onCloseConsole — Is called after the console's closed.

  • onOpenConsole — Is called after the console's opened.

  • getJsCode(code) — Is called after compilation Kotlin to JS. Use for target platform js. code — converted JS code from Kotlin.

  • callback(targetNode, mountNode) — Is called after playground's united. targetNode — node with plain text before component initialization. mountNode — new node with runnable editor.

  • getInstance(instance) - Getting playground state API.

    instance.state      // playground attributes, dependencies and etc.
    instance.nodes      // playground NodeElement.
    instance.codemirror // editor specification.
    instance.execute()  // function for executing code snippet.
    instance.getCode()  // function for getting code from snippet.

Customizing editors

Use the following attributes on elements that are converted to editors to adjust their behavior.

  • data-version: Target Kotlin compiler version:

     <code data-version="1.0.7">
     /*
     Your code here
     */
     </code>
  • args: Command line arguments.

    <code args="1 2 3">
    /*
    Your code here
    */
    </code>
  • data-target-platform: target platform: junit, canvas, js or java (default).

     <code data-target-platform="js">
      /*
      Your code here
      */
     </code>
  • data-highlight-only: Read-only mode, with only highlighting. data-highlight-only="nocursor" - no focus on editor.

    <code data-highlight-only>
      /*
      Your code here
      */
    </code>

    Or, you can make only a part of code read-only by placing it between //sampleStart and //sampleEnd markers. If you don't need this just use attribute none-markers. For adding hidden files: put files between <textarea> tag with class hidden-dependency.

    <code>
    import cat.Cat
    
    fun main(args: Array<String>) {
    //sampleStart
        val cat = Cat("Kitty")
        println(cat.name)  
    //sampleEnd                 
    }
      <textarea class="hidden-dependency">
        package cat
        class Cat(val name: String)
      </textarea>
    </code>

    Also if you want to hide code snippet just set the attribute folded-button to false value.

  • data-js-libs: By default component loads jQuery and makes it available to the code running in the editor. If you need any additional JS libraries, specify them as comma-separated list in this attribute.

    <code data-js-libs="https://my-awesome-js-lib/lib.min.js">
      /*
      Your code here
      */
     </code>
  • auto-indent="true|false": Whether to use the context-sensitive indentation. Defaults to false.

  • theme="idea|darcula|default": Editor IntelliJ IDEA themes.

  • mode="kotlin|js|java|groovy|xml|c|shell|swift|obj-c": Different languages styles. Runnable snippets only with kotlin. Default to kotlin.

  • data-min-compiler-version="1.0.7": Minimum target Kotlin compiler version

  • data-autocomplete="true|false": Get completion on every key press. If false => Press ctrl-space to activate autocompletion. Defaults to false.

  • highlight-on-fly="true|false": Errors and warnings check for each change in the editor. Defaults to false.

  • indent="4": How many spaces a block should be indented. Defaults to 4.

  • lines="true|false": Whether to show line numbers to the left of the editor. Defaults to false.

  • from="5" to="10": Create a part of code. Example from line 5 to line 10.

  • data-output-height="200": Set the iframe height in px in output. Use for target platform canvas.

  • match-brackets="true|false": Determines whether brackets are matched whenever the cursor is moved next to a bracket. Defaults to false

  • data-crosslink="enabled|disabled": Show link for open in playground. Defaults to undefined – only supported in playground.

  • data-shorter-height="100": show expander if height more than value of attribute

  • data-scrollbar-style: Chooses a scrollbar implementation. Defaults to overlay.

Supported keyboard shortcuts

  • Ctrl+Space — code completion
  • Ctrl+F9/Cmd+R — execute snippet
  • Ctrl+/ — comment code
  • Ctrl+Alt+L/Cmd+Alt+L — format code
  • Shift+Tab — decrease indent
  • Ctrl+Alt+H/Cmd+Alt+H — highlight code
  • Ctrl+Alt+Enter/Cmd+Alt+Enter — show import suggestions

Develop and contribute

  1. Fork & clone our repository.
  2. Install required dependencies yarn install.
  3. yarn start to start local development server at http://localhost:9000.
  4. yarn test to run tests. TEST_HEADLESS_MODE=true to run tests in headless mode.
  5. yarn run build to create production bundles.

kotlin-playground's People

Contributors

alexanderprendota avatar azertypow avatar bravit avatar calvellido avatar christian-draeger avatar cjbrooks12 avatar d9onis avatar dependabot[bot] avatar fgutmann avatar hhariri avatar hypnosphi avatar ilgonmic avatar kisenka avatar krutilov avatar nikpachoo avatar oversan avatar pauleveritt avatar polinb avatar satamas avatar zhelenskiy avatar zoobestik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kotlin-playground's Issues

Issues with display:none

Hi,
in some cases i'd like to hide a sample using display: none. My issue is that when i show it, it doesn't look the way it should. Example:
image

The sample is there because when i don't use display: none it renders correctly:
image

Here is a sample project that i created to show the issue. I'm using chrome version 83.0.4103.116 (Official Build) (64-bit) and my operating system is Mac Os Catalina version 10.15.5.
samples.zip

How complex could be to compile Java?

Hi,

I was reviewing concept in multiple Kotlin projects and I would like to do the same stuff with Java.
How complex could be the configuration/change of this project in order to compile Java examples?

Currently if I try to compile Java in any example:

public class Main {
    public static void main(String[] args) {
        System.out.println("This will be printed");
    }
}

https://blog.jetbrains.com/kotlin/2018/04/embedding-kotlin-playground/

I receive the following errors:

Expecting member declaration
Expecting member declaration
Expecting member declaration
Expecting member declaration
Expecting member declaration
Expecting member declaration
Expecting member declaration
Expecting member declaration
Expecting member declaration
Expecting member declaration
Function declaration must have a name

I would like to learn if it is possible to configure in some way current kotlin-playground to compile and run Java code.

Many thanks in advance

Juan Antonio

Allow to set webDemo URL as runtime parameter

Hi! In the Arrow library we are keeping a couple of forks of both Try Kotlin and Kotlin Playground. While most of the forked code is only interesting for our purposes, these days a feature request has popped up (arrow-kt#13) that might be interesting for this project too.

A way of overwriting the server URL at runtime might be interesting for other Kotlin library creators that could easily use another backend compiler in their projects while keep using the main Kotlin Playground code.

Let me know if this would be interesting for Kotlin Playground, if not I'll move to the work to our fork.

Props for the amazing work on both projects!

Add ktor to allowed imports

As kotlin pretends to be multiplatform language I suggest to allow imports of multiplatform libraries, such as ktor, which is fully multiplatform. Btw, kotlinx.coroutines.* are already supported by playground

Problem with `Ctrl + J` in Chrome + Linux

"Show generated JS code" action is bound to Ctrl + J on Linux which instead opens a Download tab in Chrome.

Could you, please, make it as an on-screen button or choose a key combination that would work on all systems?

Editor font size

Font is too big. Please add font size change ability to setting.

Add shortcut to close/hide the console

Just a shortcut to close the console with the output. When working from a laptop
console takes too much space of the screen property and you need to click
the close (X) button.

A shortcut would be very handy. (Ctrl+X for example)

Thanks!

Editor reformats code, and its formatting doesn't match the style IntelliJ uses

Example, chained method calls:

Original code:

val allowedEntrance = people
        .filter { it.age &gt;= 21 }
        .map { it.name }
        .take(5)

Reformatted by the editor:

val allowedEntrance = people
.filter { it.age >= 21 }
.map { it.name }
.take(5)

Example, lambda braces:

Original:

args.forEach { arg -&gt;
    println(arg)
}

Reformatted:

args.forEach { arg ->
              println(arg)
             }

No (manual or auto) import?

Wenn using common expressions like measureTimeMillis{} I just get an error about the unresolved reference. There seem to be no possiblity to import those other than googling it and manually copy & pasting the import path?

Enable resizing

Currently it is unable to resize the working area and output window. It will be great if I will be able to wish to play with code in full screen mode.

Expose launch function

We would like to run automatically the code when the user scroll on some examples of code.

We're currently using some hacking code to do that. It would be better if a launch function would be exposed.

feat/PR request: onOutputReady event

I'm using Kotlin Playground in an iframe, and I need to expand the iframe size based on the height of the playground.

Right now I can update the iframe size with postMessage. I use the onChange event to check if the playground height has changed (from user's editing code) and update the iframe height accordingly.

When the code is compiled and output or exceptions are displayed in the output window, the output window expands to an arbitrary size. Right now I have no way of knowing when that's happened.

I can use the onConsoleOpen event to check when the console has been opened, but when an onConsoleOpen callback is defined, it's fired during the "waitingForOutput" stage:

this.update({
      waitingForOutput: true,
      openConsole: false
});
if (onOpenConsole) onOpenConsole(); //open when waitingForOutput=true

Which is before the actual output/exceptions have been returned, and thus before the final height of the console/output window have been set.

I'm willing to make a PR to create some kind of "onOutputReady" event, if you're open to the idea?

Or of you have a better approach, I'm open to that too. Thanks!

[Bug] Online playground is not working when use `Executors.newSingleThreadExecutor().asCoroutineDispatcher()` as CorotuineDisaptcher

When Executors.newSingleThreadExecutor().asCoroutineDispatcher() is used as CorotuineDisaptcher in Kolin online playground , hardly success . ( But very occasionally successful.)
I encounted Evaluation stopped while it's taking too long️ error message.

image

code run

Code is following

import kotlinx.coroutines.*
import java.util.concurrent.Executors

fun main(){
    val dispatcher = Executors.newSingleThreadExecutor().asCoroutineDispatcher()
    val scope = CoroutineScope(Job()+dispatcher)
    scope.launch {
        println("1")
    }

    println("2")
}

I tried

  • Kotlin version v1.4.30 / v1.5.31 / v1.6.21
  • with all for JVM

but get same result.

As a side note

When I Executors.newSingleThreadExecutor().asCoroutineDispatcher() replace with newSingleThreadContext(name: String) and run , always get success and following result message : 1 2.

Execution Environment :

  • PC :
    Edition Windows 10 Home
    Version 21H2
    Install on ‎2022/‎01/‎04
    OS build 19044.1645
    Experience Windows Feature Experience Pack 120.2212.4170.0

  • Browser :
    Google Chrome version : 100.0.4896.127(Official Build) (64 bit)

(・ Country : Japan)

Thank you.

Load kotlin.js from unpkg.com

As kotlin.js versions are available on npm, it could be more interesting to load it from unpkg.com:

  1. global CDN,
  2. better caching of libraries,
  3. less load on compile server.

Changing theme dynamically

Hi, is it possible to change the theme of sample dynamically (in JS). I have a theme toggler on my page therefore i'd like to also adjust the sample theme from idea to darcula. I've tried to just change the parameter manually but it doesn't seem to update anything (probably the change is not propagated)

Technically i could just render 2 versions and hide one but this results in super bad user experience

Editor font size

Font is too big. Please add font size change ability to setting.

P.S

if you don't plan to do it, just write. Please don't give such stupid answer like
#45

Also allow execution of Groovy in the JS component

I know this is Kotlin playground.
But I thought I'd ask for this anyway as almost everything is in place already anyway,
so integrating this should not be a big deal.

For Groovy there is the Groovy web console at http://groovyconsole.appspot.com/ where you can execute code like on play.kotl.in.
If this is slightly modified to set CORS headers to allow other sites to call executor.groovy like it could be done on the http://meetspock.appspot.com/ fork, the remote execution possibility is given already:

$ curl "http://groovyconsole.appspot.com/executor.groovy" --data-raw "script=println 'FOO'"
{"executionResult":"null","outputText":"FOO\n","stacktraceText":""}
$ curl "http://groovyconsole.appspot.com/executor.groovy" --data-raw "script=println 'FOO"
{"executionResult":"","outputText":"","stacktraceText":"expecting ''', found '<EOF>' @ line 1, column 13.\n   println 'FOO\n               ^\n\n1 error\n"}
$ curl "http://groovyconsole.appspot.com/executor.groovy" --data-raw "script='FOO'"
{"executionResult":"FOO","outputText":"","stacktraceText":""}

And on the side of this JS component also everything is almost in place already.
If you change the if that says that everything non-kotlin is read-only and use a different request and response processing for Groovy it basically works already.

I gave it a very quick try and was able to have something that works in the happy path, but I'm not a trained JS dev these days, so I'm not going to do a full implementation for this. But for a trained JS dev this should be a pretty quick task and it would be really amazing if this could be added. :-)

Playground Supports Run from File, Not from Web Server

Given this page:

<html>
  <head>
    <script src="https://unpkg.com/kotlin-playground@1" data-selector=".kotlin-code"></script>
  </head>
  <body>
    <div class="kotlin-code" data-target-platform="java">
      <pre>
        <code class="hljs language-kotlin">
fun main() {
  println("hello, world!")
}
        </code>
      </pre>
    </div>
  </body>
</html>

If you load that page directly in a Web browser (file: scheme), the Playground shows the green "Run" button and allows you to execute the Kotlin code, showing the result.

If you load that page from a Web server, it does not. See, for example, this hosted copy of that page. Or, use your favorite local Web server (tested using ruby -run -ehttpd .).

I assume that this is some sort of cross-origin limitation.

However, since I do not control unpkg.com, nor do I control the default server JetBrains is supplying to execute the Kotlin scripts, I do not know what to configure on my server to make this work. I'm no expert, but from what I can see, it is JetBrain's server that would need to have the Access-Control-Allow-Origin header to say that my host is allowed to make requests of JetBrain's server.

What do I need to do to make this work? And I apologize in advance if the answer is obvious...

Thanks!

Waiting for try.kotlinlang.org

I didn't find the sequence to reproduce it but quite often the browser indicates that it is waiting for the server (even if the result seems to came back).

image

Error when creating own instance using NPM

I have tried creating my own instance using NPM, but once I added var playground = require('kotlin-playground'); to my js file I am getting ReferenceError: "navigator is not defined".

data-js-libs not ending in .js

The getJsLibraries function filters out every library that doesn't match the regex https?://.+\.js$.

We have a case where we have to append a version code after the library. e.g https://example.com/lib.js?version=1.2.

Would you be ok with making the regex more broad or removing it all together?
Does anybody know why it was introduced in the first place?

Assigning single elements to varargs in named form is forbidden in Kotlin Koans

So here is the question that always returns the error
Assigning single elements to varargs in named form is forbidden
https://play.kotlinlang.org/koans/Collections/Compound%20tasks/Task.kt
You can just copy and paste the answer to the right place and it will still throw the error. I went through the whole tutorial and almost finish it, 98% done. Just want to get this last one straight. Can you guys take a look at it? Thanks.

[Bug] Online playground is not working

pic

I don't know if this is the right place to post, but I came across the Kotlin Playground today and encountered the following error:

Exception in thread "main" java.io.FileNotFoundException: /var/task/tmp/578c4a4c065841fea2fa62b22ca58b9e/executor.policy (No such file or directory)
 at java.io.FileOutputStream.open0 (FileOutputStream.java:-2) 
 at java.io.FileOutputStream.open (FileOutputStream.java:270) 
 at java.io.FileOutputStream.<init> (FileOutputStream.java:213) 

Steps to reproduce:

  1. Go to https://play.kotlinlang.org/
  2. Click Run when the default "Hello, World" program shows up

Copy sharable link to clipboard: the button sometimes doesn't work

Thank you for the very nice Playground and the very useful sharable shortened links.

image

Expected behaviour (usually observed)

  • I click Share in the right column
  • I click the "Copy link to clipboard" button
    • The text "Copied" shows up
    • The link has been copied to the clipboard

Abnormal behaviour (often observed)

  • I click Share in the right column
  • I click the "Copy link to clipboard" button
    • Nothing happens
    • Nothing has been copied to the clipboard

Observed in Chrome 97.0.4692.71 (64-bit) Linux.

[WIN / EDGE] issue when compiling code on some pages of play.kotlinlang.org

Just checking play with edge browser, found some errors when trying to run examples 2 & 3 on this page https://play.kotlinlang.org/byExample/05_stdlib/05_existential

I get these errors on MS EDGE :

image

the first 2 request are when running the first block of code
the 2 next when running the second block
the 2 last when running the 3rd block

Encounter problems of same type on others pages as well ie. https://play.kotlinlang.org/byExample/05_stdlib/07_firstlast

Embed Kotlin Playground on dev.to

Hello,

I'm adding support for embedding kotlin playground in https://dev.to

One issue I'm having is that I would like to prevent people from using not the embedded link (from the medium tab) but the link to edit the playground.

Is there a way to distinguish which url is embedded or not?

forem/forem#3801

Integrate with reveal.js

It would be nice to integrate this with reveal.js so that we can run code in a presentation, which should be possible. Do you happen to have something like this already?

no way to pass compiler options?

I wanted to play around with context receivers and am getting the error "The feature "context receivers" is experimental and should be enabled explicitly". But if there's a way to enable it, I'm not seeing it. Is there? Is there intended to be?

Conversion of empty code

If there's nothing between opening and closing tags of an element to be converted, then conversion doesn't go properly. In the following page it doesn't happen at all:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Issue</title>
    </head>
    <body>
        <div class="kotlin-code"></div>
        <script src="https://unpkg.com/kotlin-playground@1" data-selector=".kotlin-code"></script>
    </body>
</html>

And the following code results in a malformed element:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Issue</title>
    </head>
    <body>
        <div class="kotlin-code">
            <textarea class="hidden-dependency">;</textarea>
        </div>
        <script src="https://unpkg.com/kotlin-playground@1" data-selector=".kotlin-code"></script>
    </body>
</html>

Embedded iframe - font size

Is it possible to embed the iframe from kotlin playground and pass the font size as the parameter in the URL? It would be nice to be able to embed kotlin samples on pages like slides.com so you could run the samples directly from the presentation.

Firefox "Unhandled JavaScript exception: "

When executing the following code on Firefox 64.0.2 on Mac OS, the result is Unhandeled Javascript Exception. It works fine in Chrome.

import org.w3c.dom.CanvasRenderingContext2D
import org.w3c.dom.HTMLCanvasElement
import kotlin.browser.document

fun main() {
    val canvas = document.createElement("canvas") as HTMLCanvasElement
    
    val context2d = canvas.getContext("2d") as CanvasRenderingContext2D
    context2d.font = "14px Arial" // crashes exactly here

    document.body!!.append(canvas)
}

It took quite some time to isolate the issue because there is no error description at all. The error handling code in showJsException(e) fails to extract the information of this exception. Logging the exception to the console gives some useful information. Therefore I propose to log the raw exceptions to the console in addition to displaying them nicely.

The above code works also fine in Firefox when:

  • It is run outside the kotlin-playground
  • Or when the canvas is appended to the body before accessing the rendering context

I think the underlying issue has to do with how the iframe is created and initialized. Could be related to #28.

Add option to auto-open collapsed block

The collapsed block appears when you are using //sampleStart //sampleEnd markers. This block is closed by default, which is not always convenient. So, maybe add an attribute to show it opened by default.

Wrong indent when `>` is in code

I think I've found a bug: when using the from and to parameters with the character > is present in the code the indents are screwed up.

See attached HTML for example.

test.zip

how to use external libraries

is it possible to use libraries inside of playground?
i am maintaining an open source kotlin library (currently for JVM, KotlinJS is planed) and think it would be pretty nice to have prepared examples / code snippets on how to use the library via playground in the docs.
furthermore it would be really handy whilst trying out other libraries in general.
i couldn't find something about this topic in the readme.
is this supported in any way (or even planed or let's say a valid feature request) or would i need to run my own fork of kotlin-compiler-server and add my library their (which would lead me to a bunch of drawbacks in comparison to have it as an upstream feature).

No completion when using folded code

When using folded code (with line/to attributes or //sampleStart //sampleEnd comments), the editor doesn't propose code completion.

On this example completion is working (try to change the color by typing Colors.Web.b + completion).

On the examples of this page, it's not working.

When expanding the code by clicking on the + icon, the completion is working again.

The request for completion only contains the content of the folded code (not the complete code) and also the line number is false.

Kotlin coroutines possible bug with `GlobalScope.launch`

When executing the following code snippet on Kotlin Playground or Android Kotlin Playground, an unexpected behavior occurs.

fun main() {
    GlobalScope.launch {
        delay(1000L)
        println("World!")
    }
    println("Hello!")
    runBlocking {
        delay(700L) // Testing by modifying this delay time
    }
}

Since the delay time in the runBlocking block is 700ms, the expected output would be:

Hello!

However, the actual output is:

World! Hello!

It works find when run on IntelliJ IDEA, hence I assume it might be a bug related to the Playground when combined with coroutines.

Can't get input from user

I'm trying to get a data from a user I've tried readLine() and Scanner(System.in) but it keeps returning null which means your playground doesn't support this feature.
while this is the most important part from any programming language, so I hope that you'll add it as soon as you could.

change mentions of npm in readme to yarn

Using npm can cause issues because it may resolve to different dependency versions than yarn. We have commited a yarn.lock file but no equivalent file for npm.

For that reason we should change the mentions of npm in readme.md to their equivalent yarn commands.

If I remember correctly we had already some kind of agreement on this in a dependency-related discussion in one of the pull requests.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.