March 2002
Beginner
560 pages
12h 14m
English
When a script fails with an exception message, that message provides a description of the problem, in terms that may or may not make immediate sense to you. An exception message appears along with something called a stack trace, which is a kind of history of method calls going back to the top-level script.
The script in Listing C.1 has a problem (besides being obfuscated, contrived, and otherwise useless, that is) that prevents it from running to completion.
#!/usr/bin/env ruby
def foo
return 4.0/baz(20)
end
def baz(n)
sum = 0
n.times do |i|
sum += quux(i)
end
return n + sum
end
def quux(v)
return 9/(5-v)
end
puts foo
|
The Ruby interpreter produces the following information when trying to run the script:
Read now
Unlock full access