Bill Kelly <billk / cts.com> wrote:
> I dunno if this counts as elegant or not, :)
> but a couple years ago, I used:
> 
> class String
>   def reeval(b = TOPLEVEL_BINDING)
>     eval(%Q{<<"END_REEVAL"\n} + self + "\nEND_REEVAL\n", b)
>   end
> end

I have to say this is such a really neat hack...  it says so much
about Ruby too.

I had a hard time understanding it until I realised that the first
END_REEVAL doesn't need to be in quotes.  Writing it as:

    eval("<<END_REEVAL\n" + self + "\nEND_REEVAL\n", b)

seems to work just as well.  Any reason you did it that way?

Cheers,
Navin.