From: Pit Capitain Date: 2006-07-18T03:16:03+09:00 Subject: Re: [QUIZ] Negative Sleep (#87) Ruby Quiz schrieb: > (...) > That sounds slightly impossible to implement, doesn't it? But consider > something like this: > > ( Computation.new { ... } + Sleep.new(-1) + Computation.new { ... } ).run > > (...) This is not a submission, I just wanted to show that with some evil hacks it isn't even necessary to invent a new syntax: C:\tmp>type test-negative-sleep.rb require "negative-sleep" def log msg where = caller[ 0 ] time = Time.now.strftime "%H:%m:%S" puts "#{where} #{time} #{msg}" end with_negative_sleep do log "before" sleep( -2 ) log "after" end C:\tmp>ruby test-negative-sleep.rb test-negative-sleep.rb:12 20:07:42 after test-negative-sleep.rb:10 20:07:44 before C:\tmp> Regards, Pit