--------------enig21017591C8ADCEA853DB1D75 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Peter Lynch wrote: > Hi > I am still a beginner at Ruby, and have just arrived at this in my > learning curve. > > I would like to code > not(condition1) && not(condition2) > This is accepted in irb - > not(condition1) && condition2 > but this produces a syntax error > condition1 && not(condition2) > > I do not get it (obviously). I do not even know what to ask in reply -How do I code a compound condition, without introducing extra wrappers > like - > (not(condition1)) && (not(condition2)) > > Regards > Peter > > > For compound conditions, I'd use ! instead of not, likewise && and || instead of and and or. With copious parentheses. I prefer the word variants when the result would read like a sentence - with compound booleans all hope is lost anyway, and I prefer to be able to tell terms apart from operators easier (one being letters, the other special characters). Also, due to the low binding of not, I prefer to use "unless" and "until" instead of "if not" and "while not". Also, I think the (!(condition1) && !(condition2)) is slightly bad form. Inverting the logic makes things simpler to read: (condition1 || condition2). Yay freshman discrete maths. (Although I admit to cheating, I fired up IDEA to tell me this.) David --------------enig21017591C8ADCEA853DB1D75 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (MingW32) iD8DBQFFRn/Oy6MhrS8astoRAliXAJ9gcNFuOSR55bGmYyZ3nlA74/ZBngCfZYWd kkk9U7qGW/59xdAM2PBn+JE d0 -----END PGP SIGNATURE----- --------------enig21017591C8ADCEA853DB1D75--