Blocks for scope control
- From: Arved Sandstrom <asandstrom3minus1@xxxxxxxxxxx>
- Date: Sun, 15 Jan 2012 11:50:32 -0400
for a general discussion.
I'm talking specifically about the block by itself: a pair of braces by
themselves, enclosing some code in a method. On occasion I do run across
situations where a judicious use of such a block inside a method, to
restrict variable visibility, is handy.
I almost never see anyone else using these things this way. A block in a
method always seems to be associated with a control construct or
exception handling. As any number of references point out, you wouldn't
expect to see many usages of local blocks, mainly because 99 times out
of 100 that situation is probably handled best by a new method. But in
my years of looking at Java it occurs to me that I barely see any use of
this at all...even where it wouldn't be a bad idea.
....wherever the people are well informed they can be trusted with their
-- Thomas Jefferson, 1789
- Prev by Date: Re: How can I use Operand (+ , - ) with Time
- Next by Date: Re: How can I use Operand (+ , - ) with Time
- Previous by thread: How can I use Operand (+ , - ) with Time
- Next by thread: Re: Blocks for scope control