From 63406c49712703ca63d610e75bba4ed0078c0f16 Mon Sep 17 00:00:00 2001 From: knu Date: Thu, 19 Dec 2002 20:42:50 +0000 Subject: Improve. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- sample/eval.rb | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'sample/eval.rb') diff --git a/sample/eval.rb b/sample/eval.rb index 8b582b0fdc..90b839e873 100644 --- a/sample/eval.rb +++ b/sample/eval.rb @@ -1,13 +1,13 @@ line = '' -indent=0 +indent = 0 $stdout.sync = TRUE print "ruby> " -while TRUE +loop do l = gets - unless l - break if line == '' + if l.nil? + break if line.empty? else - line = line + l + line += l if l =~ /,\s*$/ print "ruby| " next @@ -32,10 +32,9 @@ while TRUE begin print eval(line).inspect, "\n" rescue ScriptError, StandardError - $! = 'exception raised' unless $! - print "ERR: ", $!, "\n" + printf "ERR: %s\n", $! || 'exception raised' end - break if not l + break if l.nil? line = '' print "ruby> " end -- cgit v1.2.3