def find_suffix(collection, query_string) # Inject 0 so that when evaluating the block, you have # and object that responds to `+` # if the array element is equal to the query_string # add to the sum and return the sum to be used in # the next step collection.inject(0) { |sum, str| sum += 1 if str == query_string; sum } end