Spoiled by Ruby

I've been doing a lot of Ruby work lately and love the concise yet readable syntax. But its also tainting my appreciation for other languages. Instead of writing this in Ruby...

return if (!something)

... PHP/Delphi/C++ makes me write something like this:

if (!something) {
    return false;
}

Of course you can pull off this one-liner PHP/C++, but its nowhere near as readable as the Ruby version, especially when something is an expression of any complexity.

if (!something) return false;

Ah well.

2 Comments

  1. Nick Hodges said,

    October 12, 2005 @ 8:00 am

    You can, of course, return

    Result := Something;

  2. Adam said,

    October 12, 2005 @ 8:10 am

    Nick - but Delphi won’t return at that point, it’ll keep executing. The real power is in doing something like:

    print tags.join(”, “) if (tags)

RSS feed for comments on this post