In your example "unless" is applicable only to the line it appears
in. Synonym of "unless" is "if not", i.e.:
ftp.get(str) if str.index('d') != 0
Mike Dvorkin
http://www.rubywizards.com
On Sep 13, 2006, at 5:28 PM, 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-----
>
>