Exception types

Hi,

pigeon% ruby -e ‘File.open(“aa”) rescue true’
pigeon%

I don’t quite understand the “true” you used above, what I’m trying to do is
open a buch of files to process, if one of them does not exist, jump to the
next file. I’m a little confused about what should between rescue … end??
If it return true, then go to next file, if false, the loop finishes??

  1. where can I find a reference to different kind of runtime errors? It
    seems that there are no information on that (Exception Class?) in
    pickaxe…

p. 303

Could you please give me some index or whatever thing I can search? I’m
using the htmlhelp version. tks.

begin
# do something
rescue SyntaxError, NameError => boom
# do something
end

is the same than

begin
# do something
rescue SyntaxError, NameError
boom = $!
# do something
end

So, => in this case is not hash, it make sense to add into the symbol faq :slight_smile:

Shannon

···

Help STOP SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail

I don't quite understand the "true" you used above, what I'm trying to do is
open a buch of files to process, if one of them does not exist, jump to the
next file. I'm a little confused about what should between rescue ... end??
If it return true, then go to next file, if false, the loop finishes??

pigeon% ruby -e '["aa", "b.rb"].each{|f| File.open(f) rescue next; p f}'
"b.rb"
pigeon%

p. 303

Could you please give me some index or whatever thing I can search? I'm
using the htmlhelp version. tks.

This is a figure and probably it's not in the html help version

Guy Decoux

ts wrote:

p. 303

Could you please give me some index or whatever thing I can search? I’m
using the htmlhelp version. tks.

This is a figure and probably it’s not in the html help version

But it is online in some of the translations:

(ok, ok, thats from page 93, identical figure though :slight_smile:

···


([ Kent Dahl ]/)_ ~ [ http://www.stud.ntnu.no/~kentda/ ]/~
))_student
/(( _d L b_/ NTNU - graduate engineering - 5. year )
( __õ|õ// ) )Industrial economics and technological management(
_
/ö____/ (_engineering.discipline=Computer::Technology)