From: David Alan Black Date: 2001-10-30T23:55:51+09:00 Subject: [ruby-talk:23850] Re: String#each_line Hello -- On Tue, 30 Oct 2001, Alan Moore wrote: > This isn't right, is it? > > $ ruby -e '"1\n2\n\n3\n4".each {|s| p s}' > "1\n" > "2\n" > "\n" > "3\n" > "4" > > $ ruby -e '"1\n2\n\n3\n4".each("") {|s| p s}' > "1\n2\n\n" > "3\n4" > > According to the pickaxe book: > If a zero-length record separator is supplied, the string > is split on \n characters, except that multiple successive > newlines are appended together. > > As I read it, that means the second script should output: > > "1\n" > "2\n\n" > "3\n" > "4" > > ...shouldn't it? Weirdly, it works if you use '' instead of "". David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav