Nested Methods In Ruby
Join the DZone community and get the full member experience.Join For Free
Source: igrigorik [twitter.com] ... ruby's syntax allows for nested methods:
def a; def b; :b; end; b; end; a #=> :bHere's another example:
def a2 def c "hello" end c end a2 #=> "hello"Note: Even though the method is nested it still has the same scope as a non-nested method.
Opinions expressed by DZone contributors are their own.