Information Technology Reference
In-Depth Information
Methods are created using the def keyword and can accept arguments (or parameters).
M odules are created using the module keyword.
Methods may be invoked by name. Although optional, parentheses are highly recommen-
ded for readability and code portability:
my_method ( 5 )
my_method 5
Th is will execute the method named my_method with the parameter 5 .
my _method call without parentheses does the same thing.
Methods are also chainable in Ruby, so you can continue to call a method on a chain,
provided the return value responds to the method:
"String" . upcase . downcase . reverse #=> "gnirts"
 
 
 
Search WWH ::




Custom Search