On Sat, Apr 23, 2011 at 11:22 AM, Duke N. [email protected]
wrote:
Duke
IDK, but a quick study of behaviour should make it very obvious:
numbers = *0…10 # => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
numbers[0,3] # => [0, 1, 2]
numbers[1,3] # => [1, 2, 3]
numbers[2,3] # => [2, 3, 4]
numbers[3,3] # => [3, 4, 5]
numbers[0,4] # => [0, 1, 2, 3]
numbers[1,4] # => [1, 2, 3, 4]
numbers[2,4] # => [2, 3, 4, 5]
numbers[3,4] # => [3, 4, 5, 6]
numbers[0…5] # => [0, 1, 2, 3, 4, 5]
numbers[1…5] # => [1, 2, 3, 4, 5]
numbers[2…5] # => [2, 3, 4, 5]
numbers[3…5] # => [3, 4, 5]
numbers[3…7] # => [3, 4, 5, 6, 7]
numbers[4…7] # => [4, 5, 6, 7]
numbers[5…7] # => [5, 6, 7]
numbers[6…7] # => [6, 7]
numbers[7…7] # => [7]
If you’re using TextMate, you can update the comments with
command+control+shift+e. Otherwise, you might try entering each line
into
irb, and it will update for you the correct value. Or you could write a
program to cycle through inputs and print the values, something like:
numbers = *0…10
(0…3).each do |start|
result = numbers[start,3]
puts “numbers[#{start},3] # => #{result.inspect}”
end
On Sat, Apr 23, 2011 at 12:02 PM, 7stud – [email protected]
wrote:
If someone had a gun to your head and told you that you had 30 seconds
to provide an answer to that question, what would you do?
Ruby is serious business.