From: "Hal E. Fulton" Date: 2002-06-23T05:00:51+09:00 Subject: Re: What do you think of this idiom? ----- Original Message ----- From: "David Alan Black" To: "ruby-talk ML" Sent: Saturday, June 22, 2002 3:29 AM Subject: Re: What do you think of this idiom? > I think it isn't doing what you think :-) > > $ ruby getdir.rb # with "Root = './'" added > Dir = non-existent > No such file or directory - "./non-existent" > > Note that it's not using your error message, because the "if not" > branch never happens: the stat on a bad directory name raises an > exception of its own. You could use test(?d,dir) to get a true/false > test. Right! Hadn't noticed that. That's why I post these things. [snip] > s = getstr("Dir = ", "No such directory") {|dir| test(?d,dir)} Ah, that's not bad. Good idea. Hal Fulton