syntax - What do curly braces in Java mean by themselves? -
i have java code uses curly braces in 2 ways
// curly braces attached 'if' statement: if(node.getid() != null) { node.getid().apply(this); } // curly braces themselves: { list<pexp> copy = new arraylist<pexp>(node.getargs()); for(pexp e : copy) { e.apply(this); } } outamethodexp(node);
what stand-alone curly braces after first if
statement mean?
the purpose of braces provide scope-limit. list<pexp> copy
exist within braces, , have no scope outside of them.
if generated code, assume code-generator can insert code (such this) without having worry how many times has inserted list<pexp> copy
, without having worry possibly renaming variables if snippet inserted same method more once.
Comments
Post a Comment