Created
January 6, 2012 17:16
-
-
Save TwP/1571514 to your computer and use it in GitHub Desktop.
at_exit callback ordering
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The purpose of this experiment is to see if we can force our at_exit handler | |
# to be the very last one invoked regardless of the order in which the at_exit | |
# handlers are registered. The Ruby documentation states that the at_exit | |
# handlers are called in the reverse order in which they are registered. So | |
# the first one registered is the last one called. | |
at_exit { STDOUT.puts "first" } | |
at_exit { | |
STDOUT.puts "second" | |
at_exit { STDOUT.puts "LAST ONE!!" } | |
} | |
at_exit { STDOUT.puts "thrid" } | |
STDOUT.puts "exiting" | |
=begin ---- output ---- | |
exiting | |
thrid | |
second | |
first | |
LAST ONE!! | |
=end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There are some issues about this on Redmine. I think it changed in 1.9.3 (or maybe 1.9.2).