IntelliJ Ultimate Kotlin脚本REPL跳过第一行打印-临时输出被切断 [英] IntelliJ Ultimate Kotlin Script REPL skips first printed lines - Scratch Output cut off

查看:59
本文介绍了IntelliJ Ultimate Kotlin脚本REPL跳过第一行打印-临时输出被切断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢在intelliJ中使用REPL来解决编码问题,就像您在codesignal上会发现的那样.我目前有版本:

I enjoy using the REPL in intelliJ for coding problems like you would find on codesignal. I currently have the version:

IntelliJ IDEA 2019.1.3 (Ultimate Edition)
Build #IU-191.7479.19, built on May 27, 2019
JRE: 1.8.0_202-release-1483-b58 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.14.4

我一直感到困惑,因为在运行这些暂存文件中的任何一个时,我尝试将输出打印到的前5-9行将不存在.

I have always been really confused by the fact that when running any of these scratch files, the first 5-9 lines I am trying to print output to will just, not exist.

下面是一个示例程序,它将在控制台上打印出X的金字塔

Below is an example program that would print out a pyramid of X's to the console

fun createPyramid(height: Int, drawChar: String = "X") {
//    repeat(9) {
//        println("blank")
//    }

    for (i in 1 until height) {
        val blank = " ".repeat(height - i)
        val row = blank + drawChar.repeat(i * 2 - 1)
        println(row)
    }
}

createPyramid(11)

如果我已注释掉重复块,我的输出将如下所示:

If I have the repeat block commented out, my output looks like:

如果我取消注释重复,我将得到如下输出:

If I uncomment the repeat I will then get output looking like:

关于这种情况的真正令人困惑的部分是行数似乎是随机的,并且在工作方式上存在不一致之处.如果我执行 repeat(9),我通常会得到1个实际打印出来的空白"如果我大多数时候都执行 repeat(8),它实际上不会从金字塔中取出第一个预期的"X".

The really confusing part about this situation is the number of lines seem to be random, and there is inconsistencies in how it works. If I do repeat(9) I normally get 1 actually printed out "blank" If I do repeat(8) most of the time it will actually not put out the first expected "X" from the pyramid.

推荐答案

在划痕的输出将直接在编辑器中显示在表达式旁边,并提供此输出.临时输出工具窗口仅打印编辑器中不适合的输出.

Output for scratches is printed right in the editor, next to the expression, that provide this output. Scratch Output tool window prints only the output that doesn’t fit into the editor.

这篇关于IntelliJ Ultimate Kotlin脚本REPL跳过第一行打印-临时输出被切断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆