如何访问 Scala REPL 中的最后一个结果? [英] How can I access the last result in Scala REPL?
本文介绍了如何访问 Scala REPL 中的最后一个结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 python REPL 中,我可以执行以下操作:
<预><代码>>>>[1,2,3,4][1, 2, 3, 4]>>>和(_)10在 clojure REPL 中,我可以这样做:
user=>你好!"你好!"用户=>*1你好!"
Scala REPL 中有这样的东西吗?
解决方案
是的,可以用点号表示最后的结果:
scala>列表(1,2,3,4)res0: List[Int] = List(1, 2, 3, 4)标度>.和res1:整数 = 10
In python REPL I can do things like:
>>> [1,2,3,4]
[1, 2, 3, 4]
>>> sum(_)
10
In clojure REPL I can do this:
user=> "Hello!"
"Hello!"
user=> *1
"Hello!"
Is there is something like this in Scala REPL?
解决方案
Yes, you can use dot notation to refer to the last result:
scala> List(1,2,3,4)
res0: List[Int] = List(1, 2, 3, 4)
scala> .sum
res1: Int = 10
这篇关于如何访问 Scala REPL 中的最后一个结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文