From: Phillip Gawlowski on 31 Dec 2009 01:43
On 31.12.2009 06:32, Albert Schlef wrote:
> It works. But, I must say, it isn't as beautiful as my original plan. It
> doesn't read as English.
PS C:\Scripts> ruby .\unless.rb
/unless.rb:1: Argument error (RuntimeError)
PS C:\Scripts> ruby .\unless.rb "arg"
PS C:\Scripts> cat .\unless.rb
raise "Argument error" unless ARGV
I prefer it that way. :)
Works in 1.8.6 and 1.9.1, too, to my great relief.
From: Jeff Peng on 31 Dec 2009 02:13
> On Thu, Dec 31, 2009 at 10:24 AM, Albert Schlef <albertschlef(a)gmail.com> wrote:
>> Why? I thought the only diference between "or" and "||" is the
> yes, so you can do eg
>>> system "pwd" or raise "no command here"
> => true
>>> system "asdf" or raise "no command here"
> RuntimeError: no command here
> if you know perl, this is no surprise..
I know Perl, but I'm still surprised.
# perl -le 'print undef or 4'
# perl -le 'print(undef or 4)'
irb(main):001:0> puts nil or 4
irb(main):002:0> puts(nil or 4)
SyntaxError: (irb):2: syntax error, unexpected keyword_or, expecting ')'
puts(nil or 4)
from /usr/bin/irb:12:in `<main>'
And if I "puts (nil or 4)" (there is a blank between them) will print 4.
(Just my thought,I was thinking this is a bug.)
From: Seebs on 31 Dec 2009 03:22
On 2009-12-31, Albert Schlef <albertschlef(a)gmail.com> wrote:
> Why is the following a syntax error?
> puts (123 if true)
> and the following isn't?
> puts (123 or 456)
The if modifier has to go on the tail end of the containing complete
expression. You could say "statement", but I don't think that really
But that's not the same issue as why "or" doesn't work in a method argument
without extra ().
Copyright 2009, all wrongs reversed. Peter Seebach / usenet-nospam(a)seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
From: Albert Schlef on 31 Dec 2009 04:31
> On 2009-12-31, Albert Schlef <albertschlef(a)gmail.com> wrote:
>> Why is the following a syntax error?
>> puts (123 if true)
>> and the following isn't?
>> puts (123 or 456)
> The if modifier has to go on the tail end of the containing complete
Then why does the following work?
a = (123 if true)
Posted via http://www.ruby-forum.com/.
From: Phillip Gawlowski on 31 Dec 2009 04:35
On 31.12.2009 10:31, Albert Schlef wrote:
> Then why does the following work?
> a = (123 if true)
Because here you do an assignment.
Ruby Appliance's Beginner VM will need a list of Ruby gotchas. :S