From: Stephen Waits Date: 2006-03-07T18:16:36+09:00 Subject: hack to work around eval scoping? I've learned that in 1.8 eval is scoped like a block.. I'm wondering how I might get around that? For a little background, here's what I'm working on. Essentially an erb script of Ruby examples, that lists code and output neatly. It's basically similar to a non-interactive version of why's try ruby - well, in some ways. I think... :) Anyway, here's the shell of the script which demonstrates my problem, in case I haven't explained myself clearly enough: <% require 'syntax/convertors/html' include ERB::Util def output(code) result = eval(code) if result result.to_s else "nil" end end # would be nice to pass this an array # of strings to be eval'd in sequence too def ruby(code) convertor = Syntax::Convertors::HTML.for_syntax "ruby" "
" + "
" + "
" + convertor.convert( code.gsub(/\t/," ") ) + "
" + "
" + h(output(code)) + "
" + "
" end %> <%= ruby( < <%= ruby( < Thanks, Steve