Created
June 30, 2011 21:48
-
-
Save rubydubee/1057352 to your computer and use it in GitHub Desktop.
Array Example 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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