Skip to content

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 def statement or by calling the Module.define_method method
  • 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()

Clone this wiki locally