Does Scala have introspection capable of something similar to Python's dir()?

前端 未结 4 592
半阙折子戏
半阙折子戏 2020-12-25 13:10

Yes, I know it\'s considered lazy by the non-Pythonistas. The reason I ask is that documentation is still woefully lacking in many Scala libraries (e.g. Scala-dbc, but that\

4条回答
  •  悲&欢浪女
    2020-12-25 13:54

    You might want something like the following which would give you what you need. In this case, it operates on a String, obviously.

    val testStr = "Panda"
    testStr.getClass.getMethods.foreach(println)
    

    Does that work?

提交回复
热议问题