I am running ruby ββ1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux].
#!/usr/bin/env ruby def ouch() raise ArgumentError, "woof" fred = 3 return( nil ) ensure if ( defined?( fred ) ) then printf( "fred is defined (%s)\n", fred.inspect() ) else printf( "fred is not defined\n" ) end end
At startup, the output from the above ruby ββscript is quite unexpected.
$ ./ouch.rb fred is defined (nil) ./ouch.rb:4:in `ouch': woof (ArgumentError) from ./ouch.rb:22:in `<main>'
Thus, an increase / exception occurs, fred does not get the value 3, but it is determined and set to zero, thereby defeating the test for determined by? (). This is very confusing. This is mistake? Obviously, a test for certain needs needs to be tested for not zero.
If this is not a mistake, can someone explain why not?
source share