http://qs321.pair.com?node_id=11124194


in reply to Re^8: What's the right way to write a method which returns one line at a time from a file?
in thread What's the right way to write a method which returns one line at a time from a file?

As others already stated, your code is confusing and yes, my rule would forbid that.

Your code has no more value than any of these (all clearer):

if (EXPR1) { return A }; if (EXPR2) { return B }; if (EXPR3) { return C }; die "unmatched case"; EXPR1 and return A; EXPR2 and return B; EXPR3 and return C; die "unmatched case"; return A if EXPR1; return B if EXPR2; return C if EXPR3; die "unmatched case";

For short expressions, my personal preference is the middle one. The first is the best choice if it is likely that the blocks can have statements before the return.

I personally do not like statement modifiers, so I would not choose the third option, but it is still by far better than your example.

Opinions differ though. TIMTOWTDI. But you still have shown no reason why my ruling would be rediculous. You only showed an example that strenghtens my opinion on it.


Enjoy, Have FUN! H.Merijn