[英]Scala - get list of bound variables?
有什么方法可以在scala中獲取綁定變量列表?
在:power
模式2.9,2.10,和2.11可以intp.visibleTermNames.sorted.foreach(println)
得到的一切,或intp.definedTerms.foreach(println)
對於剛剛的事情你創建的。
在2.10中, $intp
始終可見(電源模式或否),因此$intp.definedTerms.foreach(println)
將在非電源模式下打印列表。
嘗試intp.
超級模式下的+ tab以列出所有可用方法。 (以$
開頭的符號未啟用制表符補全。)
在Scala 2.10 REPL中,可以訪問與REPL相關聯的IMain
實例。 它可以作為$intp
。 似乎有可能以此來深入檢查REPL狀態。
例如, $intp.unqualifiedIds
可能對您有所幫助。
在REPL中,您可以使用:dump
命令來打印REPL的內部狀態。 第一行應該是這樣的:
Names: $ires0 $ires1 $ires2 $ires3 $ires4 $ires5 $ires6 $ires7 $r x z
這些都是您在此會話中定義的所有變量,類和單例。
我不知道只顯示變量的方法。
編輯 :
在:dump
命令可用之前,您必須使用:power
進入電源模式
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.