From: Derek Smith Date: 2009-10-27T00:46:26+09:00 Subject: Re: file open failure test Bertram Scharpf wrote: > Hi, > > Am Montag, 26. Okt 2009, 18:40:20 +0900 schrieb Robert Klemme: >> If you just want the boolean information whether the open succeeded or >> not you can do this: >> >> irb(main):010:0> File.open("mm").close || true rescue false >> => true >> irb(main):011:0> File.open("not existent").close || true rescue false >> => false > > If you just want to test then ask: > > File.stat("xx").readable? > > As Robert pointed out it is better straight to do what you want to > do and catch the exceptions where they happen. > > Bertram Thanks you guys! I understand, but coming from (nasty) Perl land there are differences. But why the .close here File.open("mm").close ? What does it do... auto close at end of the block? -- Posted via http://www.ruby-forum.com/.