I have the following simplified code example:
class MyTimerClass
def timed_execution(&block)
...
end
def elapsed_time
...
return ...
end
end
...
t = MyTimerClass.new
t.timed_execution {1000.times {"foo".equal? "foo"}}
puts "block took #{t.elapsed_time} seconds to run."
What I want to do is print out "executed" on every execution of "foo".equal? "foo". Instead of putting this inside the timed_execution method I want to add it to the passed code block. something like...
t.timed_execution {1000.times {"foo".equal? "foo" puts "executed"}}
which is wrong. I guess what I really want to know is how to have multiple statements within a code block. Really simple question I know...