Sha256: 76a9f98df52025b01230972c153b2e5b055d8da4ddfc1c7187bfcb1db14c5973

Contents?: true

Size: 666 Bytes

Versions: 115

Compression:

Stored size: 666 Bytes

Contents

# encoding: utf-8
require 'open_classes/object'
require 'open_classes/module'
require 'open_classes/array/together_helper'

# Array
class Array
  include TogetherHelper

  # Arrays loop together with index.
  #
  #   alpha = %w{one two three}
  #   numbers = %w{1 2 3}
  #   [alpha, numbers].together_with_index do |first, second, index|
  #     print "#{index.to_s}:#{first}:#{second}\n"  # => output 0:one:1, 1:two:2, 2:three:3
  #   end
  def together_with_index
    if_not_contain_array_rails_type_error
    first.each_with_index do |i_v, i|
      eval_each_str = get_args_str_for_together i, true
      instance_eval "yield(#{eval_each_str})"
    end
  end
end

Version data entries

115 entries across 115 versions & 1 rubygems

Version Path
tbpgr_utils-0.0.151 lib/open_classes/array/together_with_index.rb
tbpgr_utils-0.0.150 lib/open_classes/array/together_with_index.rb
tbpgr_utils-0.0.149 lib/open_classes/array/together_with_index.rb
tbpgr_utils-0.0.148 lib/open_classes/array/together_with_index.rb
tbpgr_utils-0.0.147 lib/open_classes/array/together_with_index.rb
tbpgr_utils-0.0.146 lib/open_classes/array/together_with_index.rb
tbpgr_utils-0.0.145 lib/open_classes/array/together_with_index.rb
tbpgr_utils-0.0.144 lib/open_classes/array/together_with_index.rb
tbpgr_utils-0.0.143 lib/open_classes/array/together_with_index.rb
tbpgr_utils-0.0.142 lib/open_classes/array/together_with_index.rb
tbpgr_utils-0.0.141 lib/open_classes/array/together_with_index.rb
tbpgr_utils-0.0.140 lib/open_classes/array/together_with_index.rb
tbpgr_utils-0.0.139 lib/open_classes/array/together_with_index.rb
tbpgr_utils-0.0.138 lib/open_classes/array/together_with_index.rb
tbpgr_utils-0.0.137 lib/open_classes/array/together_with_index.rb
tbpgr_utils-0.0.136 lib/open_classes/array/together_with_index.rb
tbpgr_utils-0.0.135 lib/open_classes/array/together_with_index.rb
tbpgr_utils-0.0.134 lib/open_classes/array/together_with_index.rb
tbpgr_utils-0.0.133 lib/open_classes/array/together_with_index.rb
tbpgr_utils-0.0.132 lib/open_classes/array/together_with_index.rb