Flowdock
method

each

Importance_2
v1_8_7_72 - Show latest stable - 0 notes - Class: String
each(...) public

Splits str using the supplied parameter as the record separator ($/ by default), passing each substring in turn to the supplied block. If a zero-length record separator is supplied, the string is split into paragraphs delimited by multiple successive newlines.

   print "Example one\n"
   "hello\nworld".each {|s| p s}
   print "Example two\n"
   "hello\nworld".each('l') {|s| p s}
   print "Example three\n"
   "hello\n\n\nworld".each('') {|s| p s}

produces:

   Example one
   "hello\n"
   "world"
   Example two
   "hel"
   "l"
   "o\nworl"
   "d"
   Example three
   "hello\n\n\n"
   "world"
Show source
Register or log in to add new notes.