Ruby END 语句
语法
END {
code
}
声明 code 会在程序的结尾被调用。
实例
#!/usr/bin/ruby
puts "This is main Ruby Program"
END {
puts "Terminating Ruby Program"
}
BEGIN {
puts "Initializing Ruby Program"
}
这将产生以下结果:
Initializing Ruby Program
This is main Ruby Program
Terminating Ruby Program