Snake case

From Wikipedia, the free encyclopedia

Snake case (or snake_case), is the practice of writing compound words or phrases in which the elements are separated with one underscore character (_) and no spaces, with each element's initial letter usually lowercased within the compound and the first letter either upper or lower case—as in "foo_bar", "hello_world". It is commonly used in computer code for variable names, and function names, and sometimes computer filenames.[1]

Variant

Spinal-case or Train-Case (depending on whether it is all in lower case or not, respectively) is similar to snake_case, but spaces are replaced by hyphens ("-"), instead of underscores. As in this-is-an-example.

Screaming snake case is similar to snake_case, but letter are written in UPPERCASE, as THIS_IS_AN_EXAMPLE.


Languages that use snake case as convention

  • Perl
  • PHP, for variable names and function names
  • Python, for variable names, function names, and method names
  • Ruby

See also

References

  1. eg. in Python and Ruby; see Naming convention (programming)
This article is issued from Wikipedia. The text is available under the Creative Commons Attribution/Share Alike; additional terms may apply for the media files.