Link Details

Link 877805 thumbnail
User 984911 avatar

By knoldus
via blog.knoldus.com
Published: Nov 17 2012 / 10:46

For those of us who are coming from an imperative background, we are used to using try catch rather losely. Ok, I am not trying to generalize here but a majority of us do so. When we come to the Scala world, we realise that like other expressions in scala, try-catch-finally would result in a value. The general practice recommended is that finally should be used when we want something to be executed irrespective of whether it resulted in a value or ended up in a catch condition. A much used scenario is to clean up any resources in finally such as file.close() Now, in scala since it would yield a value, the recommendation is that you should not change the value which was computed as a part of try or catch in the finally block. What happens if you do it?
  • 9
  • 0
  • 901
  • 1386

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Voters For This Link (9)



Voters Against This Link (0)



    Java Performance Optimization
    Written by: Pierre-Hugues Charbonneau
    Featured Refcardz: Top Refcardz:
    1. Design Patterns
    2. OO JS
    3. Cont. Delivery
    4. Java EE7
    5. HTML5 Mobile
    1. Node.js
    2. Debugging JavaScript
    3. OO JS
    4. JSON
    5. Ajax