To start, you need to be clear, how to write code correctly. To do this I will explain how you should declare variables, modules, classes, constants and methods (functions). Before continuing, it is necessary to note that the words we use must be significant, i.e, should be self-explanatory and should not be ambiguous.
First, I'll start with the "Classes" you should always have a syntax in "CamelCase" format, in the same way, this also applies to the creation of "modules". Then I will set an example for that case.
class Car
end
module SportsCar
end
Second, for the declaration of symbols, variables and methods (functions), you should always use the syntax "snake_case" i.e, always write in lower case and if the word is made up of 2 or more words it should be separated by an underscore "_”. Well, now we will show an example of each.
def some_method
this_is_a_varible = 3
end
Last but not least. Always, you should remember the "constants", these should always be written in capital letters, if there is more than one word they must be separated by an underscore "_".
THIS_IS_A_CONSTANT = 4
No hay comentarios:
Publicar un comentario