Nombres de Métodos

By convention, method names begin with a lowercase letter. (Method names can begin with a capital letter, but that makes them look like constants.) When a method name is longer than one word, the usual convention is to separate the words with underscores like_this rather than using mixed case likeThis.

Method names may (but are not required to) end with an equals sign, a question mark, or an exclamation point.

An equals sign suffix signifies that the method is a setter that can be invoked using assignment syntax.

The question mark and exclamation point suffixes have no special meaning to the Ruby interpreter, but they are allowed because they enable two extraordinarily useful naming conventions.

The first convention is that any method whose name ends with a question mark returns a value that answers the question posed by the method invocation.

Methods like these are called predicates and. Predicates typically return one of the Boolean values true or false, but this is not required, as any value

The second convention is that any method whose name ends with an exclamation mark should be used with caution.



Subsecciones
Casiano Rodriguez León 2015-06-18