From: Michael Neumann Date: 2004-11-14T09:13:13+09:00 Subject: Re: assert On Sun, Nov 14, 2004 at 01:20:49AM +0900, Gavin Sinclair wrote: > On Sunday, November 14, 2004, 2:48:24 AM, Florian wrote: > > > Gavin Sinclair wrote: > > >>>>>I have thought about changing the name to "assume" so it can be included > >>>>>in dev-utils, but I'm not sure if that name is better. > >>>I think that would be way too much magic. I'd expect the method to just > >>>take a block. > >> > >> Why a block? The breakpoint code uses Binding.of_caller anyway, so a > >> block is not needed for evaluation. I don't see any other reason, > >> technical or stylistic, why a block should be preferred. > > > Using strings for code is a bit ugly. We have blocks in Ruby, why not > > use them? Using a String also causes a bit of escaping trouble (I know > > this can be worked around via the %{} or <<-END syntax, but I still > > think blocks are clearer than that.) > > Agreed, but you can print strings. You can't print blocks. See > below. Hm, has someone tried ParseTree (http://www.zenspider.com/ZSS/Products/ParseTree/) to print out blocks? Would be really great if that works. trace { x + y } #=> x+y = 5 assert { x + y == 0 } #=> assertion 'x+y==0' failed... Uhm, seems that's only possible to dump methods in classes, not arbitrary code. But maybe, it's possible. Regards, Michael