git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2002-12-19 20:42:50 +00:00
Родитель 354af9da36
Коммит 63406c4971
2 изменённых файлов: 9 добавлений и 11 удалений

Просмотреть файл

@ -1,13 +1,13 @@
line = '' line = ''
indent=0 indent = 0
$stdout.sync = TRUE $stdout.sync = TRUE
print "ruby> " print "ruby> "
while TRUE loop do
l = gets l = gets
unless l if l.nil?
break if line == '' break if line.empty?
else else
line = line + l line += l
if l =~ /,\s*$/ if l =~ /,\s*$/
print "ruby| " print "ruby| "
next next
@ -32,10 +32,9 @@ while TRUE
begin begin
print eval(line).inspect, "\n" print eval(line).inspect, "\n"
rescue ScriptError, StandardError rescue ScriptError, StandardError
$! = 'exception raised' unless $! printf "ERR: %s\n", $! || 'exception raised'
print "ERR: ", $!, "\n"
end end
break if not l break if l.nil?
line = '' line = ''
print "ruby> " print "ruby> "
end end

Просмотреть файл

@ -1,9 +1,8 @@
def fact(n) def fact(n)
return 1 if n == 0 return 1 if n == 0
f = 1 f = 1
while n>0 n.downto(1) do |i|
f *= n f *= i
n -= 1
end end
return f return f
end end