lib/sixarm_ruby_ramp/enumerable/nitems.rb
# Calls block with two arguments, the item and its index, for each item in enum.
#
# @example
#   enum.nitems_with_index {|obj,i| block }
#    => number of items
#
# @return [Integer] the number of leading elements for which block is true.
#
Calls block with two arguments, the item and its index, for each item in enum.
Calls block with two arguments the item and its index for each item in enum .
def nitems_with_index
    index = 0
    each{|item| yield(item,index) ? (index+=1) : break}
    return index
  end
def nitems_with_index index = 0 each { | item | yield ( item , index ) ? ( index += 1 ) : break } return index end
Calls block with two arguments, the item and its index, for each item in enum.
Calls block with two arguments the item and its index for each item in enum .
the number of leading elements for which block is true.
the number of leading elements for which block is true .
Integer
example
enum.nitems_with_index {|obj,i| block } => number of items
enum . nitems_with_index { |obj i| block } = > number of items