From: "Simon Kröger" Date: 2005-09-03T08:18:40+09:00 Subject: Re: Idiomatic conversion of yielding block to array Jacob Fugal wrote: > [...] > What's the second to last line for? > > l = (s1[i] == 10) ? l+1 : l > > That will always return false (since s1[i] is always a string, and > string/integer comparison is always false), so your line count will > always be 1. s1[i] is in fact never a string: str[fixnum] => fixnum or nil http://www.ruby-doc.org/core/classes/String.html#M001328 so it is for counting newline chars. It could be written shorter (s1[i] == 10) ? l+1 : l without the assignment. > Jacob Fugal cheers Simon