-
Notifications
You must be signed in to change notification settings - Fork 1
Methods
datanorris edited this page Jan 1, 2016
·
47 revisions
Key characteristics of Ruby methods:
- They are defined on a class or a module
- They are defined at runtime e.g. by the
defstatement or by calling theModule.define_methodmethod - Methods can also be redefined, removed or undefined
- Method calls are invoked on an object, and resolved at runtime using a "message-passing" paradigm - at the time of method call, the object's class and its ancestor classes are searched until one is found which has the method defined on it
- A method's "signature" is just its name - there is no overloading to allow method calls on the same method with different arguments to be resolved to different implementations
- They have powerful and flexible options for passing arguments
- They
Methods are dynamic Method signature and resolution Method missing Method invocation styles (method & command call) Method formal arguments Method call arguments Permitted method names Undefining Blocks and block arguments send()
A Ruby Language Reference
Copyright © by Michael Hore, 2016.
Introduction to This Document
Ruby Elements
- Classes and Modules
- Methods
- Blocks, Procs and Lambdas
- Execution Context and Closures
- Variables, Constants and Namespaces
- Types and Literals
- Ruby Expressions
- Operators
Syntax Grammar
Exceptions and Throw
Ruby Sourcefiles and Libraries
Multi Threading
Execution and Lifecycle