On Sep 12, 10:18 am, Jean-René Saint-Etienne <jeanrene97...@gmail.com> wrote: > Hi, > > I am a beginner in ruby and It try to undertand the concept of > "enum.chunk" in particular these 2 exemples (http://ruby-doc.org/core/ > classes/Enumerable.html#M003131) >
it groups consecutive elements according to the value of the block you supply, and returns an array of arrays, one for each group > " open("/usr/share/dict/words", "r:iso-8859-1") {|f| > f.chunk {|line| line.ord }.each {|ch, lines| p [ch.chr, > lines.length] } " > this opens a dictionary file, and then groups by the first character of each line, before outputting the size of each group (i.e. the number of words in the dictionary file beginning with that letter) Fred > and > " sep = "-"*72 + "\n" > IO.popen("svn log README") {|f| > f.chunk {|line| > line != sep || nil > }.each {|_, lines| > pp lines > } > } > " > > What do those mean ? I can't understand the way it works... > > Best regards, > > Jr -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.