2

In API documentation, and sometimes even used in discussions here on Stack Overflow, I sometimes see the pound (#) character used instead of the dot (.) as the separator between the class name and the method name. For example:

Settings#maxPageSize

I'm wondering what this usage means, and where it comes from?

Amadan
  • 179,482
  • 20
  • 216
  • 275
Landon Kuhn
  • 65,613
  • 42
  • 102
  • 130

2 Answers2

3

I've always thought that the distinction is that Settings.maxPageSize seems to imply that you can actually write just that (i.e. that it is a static method), and that the pound is there to denote that it is just a reference to a method, not a piece of code that you can execute.

Although I could be totally wrong about this =)

So for static methods, you could actually reference them Settings.maxPageSize, but for instance methods, you'd have the option of coming up with a new convention, such as Array#sort to denote that something special is going on, or, to achieve the same completeness, you'd have to write

myArray.sort // when myArray is of the type Array

EDIT

Amadan's reply seems to confirm my interpretation, with the exception that Settings.maxPageSize is not used for static methods either; rather, that would be Settings::maxPageSize, and . being reserved entirely for example code, which makes sense to me.

David Hedlund
  • 125,403
  • 30
  • 199
  • 217
3

Assuming you mean Ruby (which is the first language that I can think of with such conventions), it is explained here:

Why are methods in Ruby documentation preceded by a hash sign?

Community
  • 1
  • 1
Amadan
  • 179,482
  • 20
  • 216
  • 275