From: Siep Korteling Date: 2009-02-03T04:48:23+09:00 Subject: Re: Noob question: while or for loop within a list Darin Ginther wrote: > > list = "A,B,C,D" > list.split(", ").each do |url| > puts "URL IS:"+url > end > > Output: URL IS:A,B,C,D > > > > Is using an array a "more correct" way to do it in Ruby? Your first example began with list = "url1, irl2, url3, url4, url5" but now your list looks like this: list = "A,B,C,D" The spaces are missing, so splitting on a comma followed by a space does not split anything in your second example. In your first example, it produces an array with 4 elements. In your second list it produces an array with one elemement: "A,B,C,D" hth, Siep -- Posted via http://www.ruby-forum.com/.