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

前端 未结 4 600
半阙折子戏
半阙折子戏 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 14:02

    That's one of my main uses for REPL. Type the object's name, dot, and then TAB and it will show all available methods.

    It isn't perfect. For one thing, it shows protected methods, which won't be available unless you are extending the class. For another thing, it doesn't show methods available through implicit conversion.

    And, of course, the IDEs are all capable of doing that.

提交回复
热议问题