Exception Handling • Exercise 3/4

Ensure Block

00:00
0
20 points

Instructions

Create a function with_counter that:
1. Takes a counter array (to track calls) and a block
2. Adds :started to counter
3. Yields to the block
4. Adds :finished to counter (ALWAYS, even if error)

Use ensure for code that must run:
ruby
begin
yield
ensure
# always runs
end

Your Code

Results

Click "Run Tests" to see results