From: Jacob Fugal Date: 2006-02-04T02:29:34+09:00 Subject: Re: Golfing (was Re: Chomping and stomping) On 2/3/06, William James wrote: > Jacob Fugal wrote: > > Let me clarify. > > > > * I don't mind you golfing on the list/newsgroup. > > * I don't mind you golfing about this task. > > What egregious arrogance! Let me clarify. What you mind > doesn't matter. I didn't say it did. I was just clarifying *my opinion*. When I asked for no golfing in that thread, it was because in *my opinion* it was off-topic for that thread. When you called me on the statement, I thought I better clarify *my opinion*, hence I clarified while using the pronoun "I". You can discard *my opinion* and I don't care. Don't call me arrogant, however, for responding to a personal query with a clarification of *my opinion*. > > What I do mind is threads that were not intended as golfing threads > > being hijacked into a golf contest. > > I'm a wicked hijacker. I know I am because Mr. Fugal told me so. I never used the word wicked; please don't put words in my mouth. Hijacking a newgroup thread is not evil, wicked or in any way morally wrong. > > If I were the OP and posted a > > question, then later saw a new post in the thread stemming from that > > question, I'd expect useful input or discussion regarding my question. > > I am especially touchy about this when golfing replies are posted in > > response to a newbie question. While golf can be fun, we don't want > > the newbie to get the wrong idea that the techniques used in the golf > > are representative of how the code *should* be written. > > If you didn't want to mislead the newbie, why did you say: > 'String#chomp! is a "destructive" operation. This means that it acts in > place on its receiver and, in this case, returns nil.' Because I made a mistake. I'm glad that someone caught the mistake and brought it to light. I have learned from it. > If you didn't want to mislead the newbie, why did you post this: > > def chomper > xx = gets.chomp > until xx == "qq" > puts "hit me with a squirell!" > xx > end > end > > puts chomper > > Even if there was a way for the loop to terminate, xx would not > be returned. It has to be moved outside of the loop. > Extremely misleading. Extremely confusing to a newbie. Because I was focusing on the difference between chomp and chomp!, about which I was mistake anyways. If you compare that code against Johns original example you'll find one difference in one character: the removal of the !. I made that one change because I believed, mistakenly, that the difference between chomp and chomp! is what was breaking my code. After jumping to that premature and mistaken conclusion, I didn't take the time to proof the rest of his method. I apologize for any confusion that may have caused. > And it was extremely arrogant to post untested > code. No, it wasn't. It was lazy, yes. It was a mistake, yes. But not arrogant. > Furthermore, it was extremely rude as well as incredibly arrogant > to assert falsely that my code wouldn't work correctly when > you had not condescended to test it. Again, that was based on my incorrect assumption about chomp! always returning nil. I made a mistake. I apologize. I was not trying to be rude, just helpful. > Much better than the above code is: > > def chomper > puts "Hit me!" while gets.chomp! != "qq" > $_ > end > > It is superior in three ways. > 1. It is correct. > 2. It is clearer. > 3. It is shorter. I would argue point 2, but only due to personal taste. I concede points 1 and 3. > Naturally, Mr. Fugal's arrogance compels him to dismiss > my version by using the term "golf", hoping that you will > assume that "golf" is a Bad Thing. I did not dismiss your version because I thought it was golf. I dismissed it because I thought, mistakenly, that is was incorrect. For that I apologize. Nor have I said golf is a Bad Thing; witness my clarification to which you have responded. > Newbies, don't be afraid of $_. Matz didn't include it in Ruby > in order to tempt the unwary into becoming "evil golfers". > He included it because it is useful. Of course, Mr. Fugal's > arrogance leads him to believe that his opinion outweighs > Matz's. I never said golfing was evil. I never said or implied that Matz made a mistake by including $_. I never said or implied that $_ is not useful. And I definitely never said or implied that my opinion outweighs that of Matz. Please do not attribute views to me that I do not hold. I discouraged the use of $_ because I believe it to be less readable than using a named variable. Indeed, John's original post asked for a way to incorporate a variable into his solution in place of the $_. Jacob Fugal