From: javier ramirez Date: 2006-09-14T10:20:43+09:00 Subject: Re: Question about 'unless' (negated if) both system calls will be always invoked. The statement under "unless" scope is ftp.get(str), which will be always invoked unless str.index('d') == 0 you can use unless in two ways (shown below). The first one is a one-liner and it goes immediately after the conditioned statement. The second one marks the beginning of the conditioned block. The first one should ring a bell with perl developers and the second with C/Java/Javascript ones whatever unless condition unless condition whatever and_so_on end regards, javier Lincoln Anderson wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Using this snippet: > > dir.each { |str| > ftp.get(str) unless str.index('d') == 0 > system("mkdir " + lpath + str.split('/').index(str.length-1)) > system("cd " + lpath + str.split('/').index(str.length-1)) > } > > > Will system be called both times all the time, or will the first one > be called only when the unless condition is satisfied, or will both > calls only be enacted when the unless condition is satisfied? I've > seen examples that used else statements with unless calls, but I'm not > sure if this is needed here or not. Unless is new to me :) > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.2 (MingW32) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iD8DBQFFCKITKte2c0P8BH0RAtHAAJkBVZQ5yV8glhpACggeDPcH2RtCxgCeJRPv > PCFuN23jhfTfvcv4NP3rDBY= > =X7eL > -----END PGP SIGNATURE----- > > >