Question: Is there any better way to slice a word in ruby?
My solution:

```
str="TAMILNADU"
pairs=[]
numPairs= str.length-1
i=0
while i<numPairs do 
  pairs[i] = str.slice(i,2)
  i+=1
end

```

Result

```
["TA", "AM", "MI", "IL", "LN", "NA", "AD", "DU"] 

```

Answer: 
And another one using a positive lookahead:

```
str = 'TAMILNADU'
str.scan(/(.)(?=(.))/).map(&:join)
#=> ["TA", "AM", "MI", "IL", "LN", "NA", "AD", "DU"]

```
Another version:

```
str = "TAMILNADU"

(0...str.size-1).map{|x| str[x,2]} 
# => ["TA", "AM", "MI", "IL", "LN", "NA", "AD", "DU"]

```