Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 415 Vote(s) - 3.49 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Difference between . and #

#1
In Ruby what is the difference between those two (in code):

- `Class.method`
- `Class#method`
Reply

#2
The hash format (Class#method) is not valid ruby, but is used in documentation to describe an instance method.

Class methods are typically documented using a double-colon (Class::method).

You will see examples of both in the ruby docs (e.g.

[To see links please register here]

)

The dot format is used in code when actually *calling* a class method (Class.method), though I have seen some people (unfortunately) use it interchangeably with either the double-colon or hash in documentation.
Reply

#3
`Class#method` is not valid code. It is only used in documentation. method should be an instance method.

`Class.method` or object.method is the actual method belonging to the object. Class is an object too. It is valid code.
Reply

#4
It's a naming convention.

- use pound `#method` for instance methods
- use dot `.method` for class methods

See: [How to name RSpec describe blocks for methods][1]


[1]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through