When I use the spark-shell
I end up defining many var
, val
, and methods
. At some point I forget what I have available in my session. How do I print that?
e.g.
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;
EDIT (Clarification):
If I type the following:
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
Is there anything that I could type to print only the following for the method defined by me?
foo: (x: Int, y: Int)Int
bar: (x: Int, y: Int)Int
You can try something similar to this:
$intp.definedTerms
.map(t => s"${t.toTermName}: ${$intp.typeOfTerm(t.toTermName.toString)}")
.foreach(println)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With