How to access instance methods in the documentation?

How can I refer to an instance field when writing documentation?

Consider this code:

object Foo { val foo = 42 } class Foo { val foo = 42 } 

In Java, you can use Foo.foo for the "static" method and Foo#foo for the instance method.

But in Scala # already running for path dependent types and

 class Foo { class foo def foo = 42 } 

is a legal code, so I can’t unambiguously refer to it.

Is there any agreement what this should look like?

+6
source share
1 answer

Tough. Maybe in English, like in Foo foo ? I missed the ambiguity # . However, this is my preferred choice, as ambiguity exists only in the absence of context. When it comes to type, # has one meaning. When it comes to value or method, # has a different one.

Since types and methods / values ​​do not share the namespace, I do not see any ambiguity here.

+3
source

Source: https://habr.com/ru/post/894486/


All Articles