Skip to content

Commit

Permalink
Chapter 14. Better program loggerrr
Browse files Browse the repository at this point in the history
  • Loading branch information
tadasmajeris committed Sep 12, 2016
1 parent 56cd5b6 commit 654f1b6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ch14-blocks-and-procs/better_program_logger.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
def log desc, &block
# your code here
$nesting_depth = 0

def better_log desc, &block
puts ' ' * $nesting_depth + "Beginning \"#{desc}\"..."
$nesting_depth += 1
result = block.call
$nesting_depth -= 1
puts ' ' * $nesting_depth + "...\"#{desc}\" finished, returning: #{result}"
end

0 comments on commit 654f1b6

Please sign in to comment.