mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
[ci skip] Add more code examples for Module#anonymous?
docs
In later code examples, it is better to write how `Module#anonymous?` works.
This commit is contained in:
parent
b9d1e101b4
commit
f3de0c185a
1 changed files with 4 additions and 2 deletions
|
@ -7,7 +7,7 @@ class Module
|
|||
# m = Module.new
|
||||
# m.name # => nil
|
||||
#
|
||||
# +anonymous?+ method returns true if module does not have a name:
|
||||
# +anonymous?+ method returns true if module does not have a name, false otherwise:
|
||||
#
|
||||
# Module.new.anonymous? # => true
|
||||
#
|
||||
|
@ -18,8 +18,10 @@ class Module
|
|||
# via the +module+ or +class+ keyword or by an explicit assignment:
|
||||
#
|
||||
# m = Module.new # creates an anonymous module
|
||||
# M = m # => m gets a name here as a side-effect
|
||||
# m.anonymous? # => true
|
||||
# M = m # m gets a name here as a side-effect
|
||||
# m.name # => "M"
|
||||
# m.anonymous? # => false
|
||||
def anonymous?
|
||||
name.nil?
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue