From: Deb Date: 2012-07-31T23:56:08+09:00 Subject: Re: Help with exercise from Chris Pine's Ruby Book: Sort without using .sort On 7/30/2012 1:49 AM, Jan E. wrote: > Hi, > > Using a dummy object as a workaround and keeping it throughout the whole > program is also not that pretty. > > Why not initialize the word with gets.chomp? This also allows you to get > rid of the somewhat redundant "if word == ''": > > word = gets.chomp > until word.empty? > words.push word > word = gets.chomp > end > > And of course there are also one-liners for this. > > What I also would like to note: These low level sorting algorithms are > certainly interesting and teach you a lot about general programming, but > they have very little to do with "the Ruby way" of doing things. > > I mean, with all that "for" and "while" loops and counters, the code > looks almost like good old BASIC. Ruby generally tries to avoid this low > level stuff in favor of a more abstract, more "intelligent" approach > (which is hardly possible in this case). > > Just so that you know that Ruby is not just some kind of prettified > BASIC. ;-) > > Hi, > > Using a dummy object as a workaround and keeping it throughout the whole > program is also not that pretty. > > Why not initialize the word with gets.chomp? This also allows you to get > rid of the somewhat redundant "if word == ''": > > word = gets.chomp > until word.empty? > words.push word > word = gets.chomp > end > > And of course there are also one-liners for this. > > What I also would like to note: These low level sorting algorithms are > certainly interesting and teach you a lot about general programming, but > they have very little to do with "the Ruby way" of doing things. > > I mean, with all that "for" and "while" loops and counters, the code > looks almost like good old BASIC. Ruby generally tries to avoid this low > level stuff in favor of a more abstract, more "intelligent" approach > (which is hardly possible in this case). > > Just so that you know that Ruby is not just some kind of prettified > BASIC. ;-) I have been pondering why you posted any response at all to my 'solution.' I did preface it by saying I had been a pogrammer in the 80s. At that point in Chris Pine's tutorial next to nothing has been covered about object oriented programming or 'the Ruby way.' Your post was not helpful, and mostly denigrating. Just saying. Learning the Ruby way is the reason for doing these little tutorials. The purpose of my response was to show a solution that worked, but maybe I was wrong to even think I could participate in this forum since I don't quite understand 'The Ruby Way' yet.