summaryrefslogtreecommitdiff
path: root/sample/eval.rb
diff options
context:
space:
mode:
Diffstat (limited to 'sample/eval.rb')
-rw-r--r--sample/eval.rb19
1 files changed, 9 insertions, 10 deletions
diff --git a/sample/eval.rb b/sample/eval.rb
index 24a352d94f..ed4b7c3de5 100644
--- a/sample/eval.rb
+++ b/sample/eval.rb
@@ -1,13 +1,13 @@
line = ''
-indent=0
-$stdout.sync = TRUE
+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
@@ -31,11 +31,10 @@ while TRUE
end
begin
print eval(line).inspect, "\n"
- rescue
- $! = 'exception raised' unless $!
- print "ERR: ", $!, "\n"
+ rescue ScriptError, StandardError
+ printf "ERR: %s\n", $! || 'exception raised'
end
- break if not l
+ break if l.nil?
line = ''
print "ruby> "
end