F
Frisco Del Rosario
myArray = [1, 2, 3]
puts myArray
myArray.each {|x|
if x == 1
then puts "one"
elsif x == 2
then
myArray.delete x
elsif x == 3
then puts "three"
end
}
puts myArray
The output of the above is:
1
2
3
one
1
3
And my question is "why isn't it 1 2 3 one three 1 3?". What if I wanted
to make it so?
puts myArray
myArray.each {|x|
if x == 1
then puts "one"
elsif x == 2
then
myArray.delete x
elsif x == 3
then puts "three"
end
}
puts myArray
The output of the above is:
1
2
3
one
1
3
And my question is "why isn't it 1 2 3 one three 1 3?". What if I wanted
to make it so?