jsnark wrote in post #1109941:
> Write a loop that generates the desired indexes and then reference arr:
>
> (0..5).each do |j|
> i = 10*j
> puts "#{arr[i]} at #{i}"
> end
>
> Your example output does not match the code. It does not include 0, 20,
> and 40.
# Print every 10th object
(0..50).each_slice(10) { |slice| p slice[0] }
0
10
20
30
40
50
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/6ac2266efa2580437413cfc45d8d31c8%40ruby-forum.com?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.