Ruby has an else block that would go in a begin/rescue (try/catch for .NET folks)
begin
#some code
rescue
#oh noes! Catches errors like catch blocks in .NET
else
#only executes when NO errors have occured
ensure
#always executes - just like the finally in .NET
end
The code in the else block will only execute if no errors have been raised. Is there a construct in .NET that provides this functionality?
In .NET, you can just list the code after
#some code:Any exception within
// some codewill prevent the “Only executes” section from occurring, as it will jump to thecatchthenfinally.