Scala: companion objects and “new” keyword

徘徊边缘 提交于 2019-12-05 03:00:29

In the Scala API documentation, you see a little icon

in the list on the left side. If you click on that, you go to the documentation of the companion object of the class or trait that's mentioned.

Most of the collection classes and many other classes in the standard library have companion objects with apply methods.

For case classes, the Scala compiler automatically creates a companion object with an apply method (as well as other methods).

Nicolas

In the scala API documentation, you can access the companion object by clicking on the icon

as explained by Jesper, but you can also switch between a class and its companion object by clicking on the class/object symbol on the top of the main panel:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!