Гарантированное выполнение (finally)

Обработка исключений

def throw_if_true(param)
    begin
        raise "test exception" if param
    rescue Exception => e
        puts "rescue"
    ensure
         puts "ensure"
    end
end

throw_if_true(true)
# печатается: "rescue" и "ensure"
throw_if_true(false)
# напечатано только "ensure"