Mar*_*ace 4 shell scala apache-spark
当我用spark-shell我最终定义很多var,val和methods.在某些时候,我忘记了我在会话中提供的内容.我该如何打印?
例如
val x = 10;
var y = 15;
def myMethod(input: Int): Int = { input * 2 }
// invoke magic print command to obtain something like:
// > val x;
// > var y;
// > myMethod(input: Int): Int;
Run Code Online (Sandbox Code Playgroud)
编辑(澄清):
如果我键入以下内容:
scala> def foo(x: Int, y: Int): Int = { x * y }
foo: (x: Int, y: Int)Int
scala> def bar(x: Int, y: Int): Int = { x / y }
bar: (x: Int, y: Int)Int
Run Code Online (Sandbox Code Playgroud)
对于我定义的方法,是否有任何我可以键入的内容仅打印以下内容?
foo: (x: Int, y: Int)Int
bar: (x: Int, y: Int)Int
Run Code Online (Sandbox Code Playgroud)
你可以尝试类似的东西:
$intp.definedTerms
.map(t => s"${t.toTermName}: ${$intp.typeOfTerm(t.toTermName.toString)}")
.foreach(println)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1119 次 |
| 最近记录: |