Naming
Use
snake_case
for methods and variables.
[link]Use
CamelCase
for classes and modules. (Keep
acronyms like HTTP, RFC, XML uppercase.)
[link]Use
SCREAMING_SNAKE_CASE
for 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 modifyself
or 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('.')