有没有快速的方法来显示Scala控制台中声明的方法的代码?

在我实际将其写入项目之前,我经常使用 Scala控制台来评估和测试代码.如果我想知道变量的内容,我可以输入它并且scala对它进行求值.但是还有一种方法可以显示我输入的方法代码吗?

我知道有UP键显示单行,但我要搜索的是立即显示整个代码.

解决方法

您的主目录中有一个名为.scala_history的文件,其中包含您最近的所有REPL历史记录.我经常将此文件中的代码复制并粘贴到项目源文件中.它与显示REPL中各个方法代码并不完全相同,但它可能有助于您实现相同的目标.

有关REPL中某些相关功能的讨论(历史中的分组语句),请参阅Paul Phillips在this issue中的评论

At some point I implemented the logic for this,but the real obstacle
is jline. It has enough trouble figuring out where the cursor is under
the simplest conditions. Start throwing big multiline blocks into the
history and it breaks down in tears. Would love to see this and
SI-2547 addressed by the community.

I expect to fix this soon too,but it depends on how well the recent
jline work goes. I implemented it long ago,and display issues are the
impediment.

这两个评论都超过两年了,所以我不会屏住呼吸.

相关文章

共收录Twitter的14款开源软件,第1页Twitter的Emoji表情 Tw...
Java和Scala中关于==的区别Java:==比较两个变量本身的值,即...
本篇内容主要讲解“Scala怎么使用”,感兴趣的朋友不妨来看看...
这篇文章主要介绍“Scala是一种什么语言”,在日常操作中,相...
这篇文章主要介绍“Scala Trait怎么使用”,在日常操作中,相...
这篇文章主要介绍“Scala类型检查与模式匹配怎么使用”,在日...