Skip to content

Instantly share code, notes, and snippets.

@guilleiguaran
Last active August 29, 2015 14:13
Show Gist options
  • Save guilleiguaran/966c2236e5037d0d4a6e to your computer and use it in GitHub Desktop.
Save guilleiguaran/966c2236e5037d0d4a6e to your computer and use it in GitHub Desktop.
class MArray < Array
def self.wrap(value)
new([value])
end
def self.empty
new([])
end
def +(other)
MArray.new(super(other))
end
def join
MArray.new(reduce([]) { |result, array| result << array })
end
def pass(&block)
MArray.new(map(&block)).join
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment