Skip to content

Instantly share code, notes, and snippets.

@rubydubee
Created June 30, 2011 21:48
Show Gist options
  • Save rubydubee/1057352 to your computer and use it in GitHub Desktop.
Save rubydubee/1057352 to your computer and use it in GitHub Desktop.
Array Example 4
array = ['junk', 'junk', 'junk', 'val1', 'val2']
3.upto(array.length-1) { |i| puts "Value #{array[i]}" } #This is an example of Integer#upto
array = ['1', 'a', '2', 'b', '3', 'c']
0..array.length-1).step(2) do |i| # This is an example of Range#step
puts "Letter #{array[i]} is #{array[i+1]}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment