[Ruby] naming convention

A variable

1, local variables

  Lowercase letters or underscore beginning, containing letters, underscores and numbers . Such as: x, string, first_name. When naming a combination of words separated by an underscore, not to camel named.

2, instance variables

  With the @ symbol at the beginning, followed by a character named the same as local variables. Such as: @ age, @ last_name.

3, class variables 

  @@ begin with, the characters following the same naming local variables. Such as: @@ running_total.

4, global variables

  To sign $ dollar at the beginning, followed by random characters, love Za Za. Such as: $ stdin, $ population.

Second, the constant

  With a capital letter at the beginning, it can be both uppercase letters, and more combinations of words separated by underscores, or named by camel. Such as: String, STDIN, FirstName, FIRST_NAME .

Third, the method name

  Named to comply with local variable naming , special order? ,! , Or = end. Such as: add, minus.

Fourth, the class name

  With a capital letter at the beginning. Such as: Person, Animal.

 

Guess you like

Origin www.cnblogs.com/xiaozhupi/p/11366975.html