code_junkie

Is it legal and possible to access the return value in a finally block?

Nov 12th, 2011
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. Dim RetVal as RetType
  2.  
  3. try
  4. ...
  5. if ... then
  6. RetVal = RetType.FailedParse
  7. end try
  8. endif
  9. ...
  10.  
  11. finally
  12. select case RetVal
  13. case ...
  14. UserStr = ...
  15. end select
  16. end try
  17.  
  18. return RetVal
  19.  
  20. SomeType result = default(SomeType); // for "definite assignment"
  21. try {
  22. // ...
  23. return result;
  24. }
  25. finally {
  26. // inspect "result"
  27. }
  28.  
  29. Public Function MyFunc() as integer
  30. Try
  31. if DoSomething() = FAIL Then
  32. return FAIL
  33. end if
  34.  
  35. Finally
  36. if MyFunc = FAIL then
  37. Me.ErrorMsg = "failed"
  38. endif
  39. End Try
  40. End Function
  41.  
  42. if MyFunc = FAIL Then
  43.  
  44. if MyFunc() = FAIL Then
Add Comment
Please, Sign In to add comment