What is the code convention name for variables that use _?

Asked

Viewed 63 times

4

If variables declared as such:

var camelCase = "";

follow the pattern camelCase, what is the default name for variables that use the _, as below?

ruby_var = "a questão vale 10 pontos =)"
  • 2

    It’s called snake_case: https://www.chaseadams.io/posts/most-common-programming-casetypes/

1 answer

3


It is usually called Snake Case, or snake_case as some prefer. This style states that any space between the words that form a unique identifier is replaced by a undeline, since the identifier cannot contain spaces. Some understand that this makes the identifier more readable than other options like camelCase or Pascalcase that eliminate space and make the initial uppercase to indicate the next word.

I think it’s ugly, but that kind of thing is taste. Of course, you should use what everyone in that language usually uses, so your code gets less alien, so I tend to try to adopt the same language pattern, but not always.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.