-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Randy Kramer wrote: > On Thursday 14 September 2006 01:14 am, Mike Dvorkin wrote: >> In your example "unless" is applicable only to the line it >> appears in. Synonym of "unless" is "if not", i.e.: > > Not the OP, but thank you! Somehow "if not" resonates better in my > head than "unless". I wonder if many other people, not yet > intimate with unless in Ruby, find it the same. > > Probably too late to change, and I'm not advocating a change, but > if I were writing a new programming language ... > > (I.e., ifnot, somewhat analogous to the elseif construct in some > languages). > > Randy Kramer > > VB has an IsNot operator: If IsNot(a) Then But I actually like the unless instruction, as it sets an action that you want to process except in a certain case. The code snippet I posted is part of a series of FTP functions I'm writing for an ftpmirror style script. In that case, I want the client to FTP#get items from a directory listing (obtained through a recursive listing funtion adapted from a snippet provided by Vincent Arnoux) unless the item is itself a directory. In that case, I want it mkdir on the client side a directory of the same name and structure as the one it encounters. the revised snippet is: #untested def dget(ftp,dir,lpath) tpath = lpath dir.each {|str| ftp.get(str) unless str.index('d') == 0 else str = str.split('/') tpath += str[str.length-1] system("mkdir " + tpath) system("cd " + tpath) end } end I assume this works better? Or in order to use else do I need to switch to a multiline unless statement: unless str.index('d')==0 ftp.get(str) else ... end Your continued insight is much appreciated. Lincoln Anderson -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFCcNZKte2c0P8BH0RArnPAJ404FGw2tIw6ObdMX/wVbOM8DSR2gCfSqvV MR+oEW9UYpFOEVc2m7nh9rs= =QUwh -----END PGP SIGNATURE-----