public
Created

Gist #5 For "Functional Programming Techniques With Ruby: Part I"

  • Download Gist
gist_5_functional_ruby.rb
Ruby
1 2 3 4 5 6
def module_split(module_path, separator = "::")
modules = module_path.split(separator)
modules.length.downto(1).map { |n| modules.first(n).join(separator) }
end
 
module_split("W::X::Y::Z")

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.