Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # our mystery method
- def with_timer
- t = Time.now
- yield
- Time.now - t
- end
- # example usage
- time_to_speak = with_timer {%x[say hello there andrew]}
- puts "speaking took #{time_to_speak} seconds"
- =begin
- Matt....The program computes how long it takes to run the code within the block %x....The only thing I am unsure of is what # the %x is for... Also note that I got rid of the do block to clean it up...
- =end
Add Comment
Please, Sign In to add comment