Project

General

Profile

Actions

Feature #8391

closed

Introduce Object.singleton_method(:sym)

Added by stephenmurdoch (stephen murdoch) almost 11 years ago. Updated almost 11 years ago.

Status:
Closed
Target version:
[ruby-core:54914]

Description

=begin
In the code below:

module A
def self.hello end
def world end
end

We can reflect on the instance method like so:

A.instance_methods # => [:world]
A.instance_method :world # => #<UnboundMethod: A#world>

It's neat, but when we come to the singleton:

A.singleton_methods # => [:hello]
A.singleton_method :hello # => undefined method `singleton_method' for A:Module

I find (({Object.singleton_method(:sym)})) more syntactically consistent than (({Object.method(:sym)})).
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0