This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest/autorun' | |
def count_all_elements(array) | |
element_count = 0 | |
array.each do |el| | |
# Given Ruby's duck-typing, it makes more sense to check for iterable | |
# objects than for integer-like objects. Otherwise we'd do more | |
# thorough type-checking. | |
if el.respond_to? :each |