Skip to content

Instantly share code, notes, and snippets.

@leejarvis
Created June 1, 2015 21:28
Show Gist options
  • Save leejarvis/c82c3b95bb7f1fe72d40 to your computer and use it in GitHub Desktop.
Save leejarvis/c82c3b95bb7f1fe72d40 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
module Enumerable
def nested_count
first.respond_to?(:nested_count) ? 1 + first.nested_count : 0
end
end
p [[[1,2,3]]].nested_count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment