From: Marnen Laibow-Koser Date: 2009-12-31T18:59:29+09:00 Subject: Re: Why can't I use "or" here? Albert Schlef wrote: > Albert Schlef wrote: >> Well. it turns out there aren't that many ways in ruby. >> >> I originally tried to do the following: >> >> some_func(ARGV[0] or raise "You must provide an argument") >> >> I wish it worked. But it doesn't. So I changed it to: >> >> some_func(ARGV[0] || raise "You must provide an argument") >> >> It still didn't work. So finally I did: >> >> some_func(ARGV[0] || (raise "You must provide an argument")) >> >> It works. But, I must say, it isn't as beautiful as my original plan. It >> doesn't read as English. > > Hey, I now see that this works: > > some_func((ARGV[0] or raise "You must provide an argument")) > > Great. On the other hand, I won't be able to remember this the next time > I need it. Just use Ruby's rescue syntax instead of trying to be clever. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen@marnen.org -- Posted via http://www.ruby-forum.com/.