Simpler Conditional Testing

| | | |

With all the recent talk and buzz surrounding the unsurprising Ruby programming language, I couldn‚Äôt help but think about other ways to simplify programming.  Consider the following:

if (foo == bar, baz, "faz")

Why not use syntax like that featured above to mean "If foo equals bar, or foo equals baz, or foo equals the string 'faz'"?

This would be equivalent to this common way of testing one variable against multiple values:

if (foo == bar || foo == baz || foo == "faz")

I think such a syntax would jive perfectly with Ruby's DRY (Don‚Äôt Repeat Yourself) principle, which essentially prefers as little code repetition as possible, and with its parallel assignment.  And of course, I would love to see this implemented in other languages, too.

What do you think?

Page Outdated! Comments disabled!

As do many people using Drupal to power their website, I get a lot of comment spam, and Drupal's spam filter is horrible! So I have permanently disabled comments on old.alanhogan.com. Try the new version of this page (which may not exist, but should if this page actually has content besides a list of other articles).

Consider using my contact form to get in touch. And remember that AlanHogan.com is live and old.alanhogan.com is here as a backup only, and a stopgap measure because some AlanHogan.com functionality is not implemented yet.

Sponsored by

To advertise here, contact me.