[Ruby] About variable naming rules. Also naming conventions for constants, classes, and methods.

This is a personal memo.

In JS, there are declarations such as let and const when defining variables, but in ruby ​​there are no declarations in particular, so I tried to find out how to distinguish them, so I summarized them.

Target Naming convention Illustration
variable Lowercase. Connect with Ansco product_name
constant All uppercase. Connect with Ansco PLODUCT_PRICE_LIST
class Only the beginning is capitalized. Camel ProductCategory
Method Lowercase. Connect with Ansco show_price_list

The constants are all uppercase, so they are easy to distinguish. Don't use hyphens.

Recommended Posts

[Ruby] About variable naming rules. Also naming conventions for constants, classes, and methods.
[Ruby] Singular methods and singular classes
About Ruby classes and instances
Ruby methods and classes (basic)
[Ruby] Singular methods and singular classes
About Ruby methods
About the difference between classes and instances in Ruby
Be careful about Ruby method calls and variable references
[Ruby] Classes and instances
About classes and instances
About Ruby instance methods
Ruby classes and instances
Ruby variables and methods
About for statement and if statement
Ruby classes are constants, not
[Java] Generics classes and generics methods
About naming Rails model methods
About Ruby hashes and symbols
About classes and instances (evolution)
About pluck and ids methods
Consideration about classes and instances
About Ruby and object model
Ruby variables and functions (methods)
Creating Ruby classes and instances
Java abstract methods and classes