Posted By

inkdeep on 03/10/10


array ruby block collection

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


Ruby array collect with index

 / Published in: Ruby

  1. # returns: ["0: a", "1: b", "2: c"]
  2. %w(a b c).enum_for(:each_with_index).collect { |o, i| "#{i}: #{o}" }

Report this snippet  

You need to login to post a comment.