Singleton Methods
In Ruby, methods can be defined that are
associated with specific objects only. Such methods are called
singleton methods. Singleton methods are defined using
def
statements while specifying a receiver.
Defines a singleton method associated with a specific object
specified by a receiver. The receiver
may
be a constant (literal) or an expression enclosed in parentheses.
Get Ruby in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.