We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 56cd5b6 commit 654f1b6Copy full SHA for 654f1b6
ch14-blocks-and-procs/better_program_logger.rb
@@ -1,3 +1,9 @@
1
-def log desc, &block
2
- # your code here
+$nesting_depth = 0
+
3
+def better_log desc, &block
4
+ puts ' ' * $nesting_depth + "Beginning \"#{desc}\"..."
5
+ $nesting_depth += 1
6
+ result = block.call
7
+ $nesting_depth -= 1
8
+ puts ' ' * $nesting_depth + "...\"#{desc}\" finished, returning: #{result}"
9
end
0 commit comments