From: Rich Kilmer Date: 2002-04-30T21:51:54+09:00 Subject: RE: An example of the beauty of Ruby... OK...about as nitpicking as it gets... upload unless unchanged? Per the standard Rubyism of the question mark for Boolean methods. -Rich :) > -----Original Message----- > From: Hal E. Fulton [mailto:hal9000@hypermetrics.com] > Sent: Tuesday, April 30, 2002 1:49 AM > To: ruby-talk ML > Subject: An example of the beauty of Ruby... > > Who was it who said something like, "In Ruby, > my thoughts flow directly into code"? > > I ran across this example I thought I'd share. > > I've been working on a simple application that > will download files for editing, invoke an editor, > and re-upload afterward. > > Then I thought to myself: "Hmm. But I don't really > want to bother uploading the file if it doesn't change." > > So I wrote this bit of pseudocode: > > upload unless unchanged > > (Being a product of the 1980s, I think in pseudocode... > I have even had to draw [shudder] flowcharts in one > or two college courses... but don't tell anyone.) > > So I thought: "Hmm. I could put all the relevant > information into instance variables. Then the method > could access them as needed. Why don't I just call it > 'upload'? Then put an if-statement around it to handle > the change check... wait a minute. I could have a method > called 'unchanged' for that." > > So I wrote this line of code: > > upload unless unchanged > > Deja vu, anyone? > > BTW, although this app is still rather clunky, I'll announce > it soon so that people can suggest improvements, fixes, > and so on. (I call it RubyRED, for Ruby Remote Editor. > It's one of those names which, if I didn't use, someone > else would.) > > Cheers, > Hal Fulton >