From: Michael Neumann Date: 2004-11-17T23:28:06+09:00 Subject: Re: assert Gavin Sinclair wrote: > On Wednesday, November 17, 2004, 8:14:47 PM, Jeff wrote: > > > >>Why not a function like .... #breakpoint? ? > > >>That would then look very much like an assert. > > >>b = 5 >>breakpoint? b == 5 ? false : true > > >>Yes/No? I kinda like the question syntax of it.... like should I break? > > > Well, I think > > breakpoint unless b == 5 > > is clearer. But that's missing the point. Any special method should > have some value over the above statement. Like > > breakpoint_unless 'b == 5' How about this: def breakpoint file, line_no = caller.first.split(':', 2) reason = File.readlines(file)[line_no.to_i - 1]. strip.sub(/^breakpoint\s+/, '') p reason # setup irb session etc. end a = 4 breakpoint unless a == 5 This extracts the "unless a == 5" out of the source file. Of course, that does not work for evaled-code (unless the source-buffer is stored somewhere and we could access it). But I'm sure, I'm missing something. Regards, Michael