From: Robert Klemme Date: 2004-06-05T18:23:39+09:00 Subject: Re: Check assertion in Ruby "David Garamond" schrieb im Newsbeitrag news:40C18065.8000704@zara.6.isreserved.com... > Paul Brannan wrote: > > On Sat, Jun 05, 2004 at 05:51:44AM +0900, Jean-Hugues ROBERT wrote: > > > >>if DEBUG > >> def assert > >> raise "assertion failure" unless yield > >> end > >>else > >> def assert; end > >>end > >> > >>There is some overhead when not in DEBUG mode, but that > >>is the best you can do in Ruby as far as I know. > > > > That's the best I know of that you could do in pure ruby. > > Is anyone using cpp (C preprocessor) along with Ruby? I've always wanted > to use it, but my laziness prevails everytime :-) Aaaargh! Even Bjarne would be glad of getting rid of this fossile and you walk around freely and try to get people to use it! Get hold of him, arrest him, put him in chains... :-)) Seriously, who needs CPP when there is Ruby? def load_special(file) if DEBUG load file else Object.new.instance_eval File.read(file).gsub(/^\s*assert\b/m, '#' ) end end Regards robert