Naming
Naming
-
Use
snake_casefor methods and variables.
[link] -
Use
CamelCasefor classes and modules. (Keep
acronyms like HTTP, RFC, XML uppercase.)
[link] -
Use
SCREAMING_SNAKE_CASEfor other
constants.[link] -
The names of predicate methods (methods
that return a boolean value) should end in a question mark.
(i.e.Array#empty?).[link] -
The names of potentially “dangerous” methods
(i.e. methods that modifyselfor the arguments,exit!, etc.) should
end with an exclamation mark. Bang methods should only exist if a non-bang
method exists. ([More on this][ruby-naming-bang].)
[link] -
Name throwaway variables
_.
[link]
version = '3.2.1'
major_version, minor_version, _ = version.split('.')
