On Tue, Jul 17, 2012 at 4:36 PM, <[email protected]> wrote: > jon_r45 sent you the following message: > > ==================================== > Do you mind explaining to me how the code > > {|l| l[/^\s*([^:\s]+)/, 1]} > > gets me what I want. I still don't see how the : and everything after > it is being dropped. > ====================================
This is a code block which is used with #map in my code snippet. It will convert the line into the leading portion. The main trick here is method String#[] with a regular expression and a group index which selects the portion of the match to be returned. I recommend to decompose the code and try out individual parts in IRB so you get familiar with how it works. Cheers robert PS: Please do not ask via private email. -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/ -- You received this message because you are subscribed to the Google Groups ruby-talk-google group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at https://groups.google.com/d/forum/ruby-talk-google?hl=en
