Create a gist now

Instantly share code, notes, and snippets.

Gist #5 For "Functional Programming Techniques With Ruby: Part I"
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")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment