On 08/24/2011 06:22 PM, Walter Bright wrote:
On 8/24/2011 1:09 AM, kennytm wrote:
Not sure if it's a big enough problem, but what about dangling else of
this
form?

if (a.length> 0)
foreach (i, ref e; a)
if (i> 0)
e += a[i-1];
else // oops
throw new Exception("empty array");

That wouldn't be complained about with what I suggested. This isn't the
dangling else problem, though, it's just bad indenting.

I'd say this is actually the dangling else problem. (When it occurs, it is always just bad indenting) Without the tie-breaker, the code snippet would be ambiguous. That is a case that should be catched.

Reply via email to