This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Local Variable Scope

 
Craig Oliver
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From what I understand:
Local (method) variables can be declared anywhere in code of method.
They are then available for rest of method.

Question is:
If local variable is declared within try/catch exception block is scope of this variable only within try/catch block or entire method from then on?
 
Vicken Karaoghlanian
Ranch Hand
Posts: 522
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can refer to (�14.4.2) for more information about the scope of local variables.
 
Babar Qadri
Ranch Hand
Posts: 51
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only within try/catch block. And refer the link given by Vicken.
cheers.
 
Mike Gershman
Ranch Hand
Posts: 1272
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The key word is block.

Variables declared within a block { ... } are only known within that block.
The individual try, catch, and finally blocks are examples of this.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic