# How to start a subscript from an arbitrary number in Ruby iterative processing

# Introduction

As the title says, it was personally convenient to start the subscript with an arbitrary number when repeating an array with each_with_index in Ruby, so I will leave it as it is.

# manner

Just change ʻeach_with_index` to ʻeach.with_index (n)`

.
Specify the start number for n.
To start the subscript from 1, write as follows.

## code

```
juices = ["tea", "cola", "coffee"]
juices.each.with_index(1) do |juice, i|
puts "#{i}Third:#{juice}"
end
```

## Output result

```
First: tea
Second: cola
Third: coffee
```

With ʻeach_with_index`, it is necessary to set ʻi + 1`

, so this method is convenient.