Albert S. wrote:
Albert S. 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
[email protected]