When running this this with the -w option I get the following
warning:
ex1.rb:4: warning: ambiguous first argument; make sure
My first question when seeing this was: make sure what ???
I thought that maybe the output on my terminal was garbled in some
way, but after looking at the source code it seems that the message
is exactly as quoted above.
The warning disappears if I put parenteses around the parameters to
the gsub! method.
But I still wonder what the warning is trying to say.
Does anybody know ?
the trend seems to be the poetry mode is evil, and being phased out. is that
fair to say?
i for one, love writing
open path, ‘r’
vs
open(path, ‘r’)
and even then would prefer
open (path, ‘r’)
in case of extreme nesting - for clarity
but i appear to be in the minority
-a
···
On Fri, 18 Apr 2003, Yukihiro Matsumoto wrote:
Hi,
In message “Cryptic -w warning: ambiguous first argument; make sure …” > on 03/04/18, Johan Holmberg holmberg@iar.se writes:
I wrote something like
str = “banana”
str.gsub! /a/, “*”
puts str
When running this this with the -w option I get the following
warning:
ex1.rb:4: warning: ambiguous first argument; make sure
make sure whether what you wrote is either
regexp as the first argument
division “str.gsub! / a”
wrap arguments with parentheses, if you don’t want to see the
warning.
–
Ara Howard
NOAA Forecast Systems Laboratory
Information and Technology Services
Data Systems Group
R/FST 325 Broadway
Boulder, CO 80305-3328
Email: ara.t.howard@fsl.noaa.gov
Phone: 303-497-7238
Fax: 303-497-7259
====================================
I feel that the “make sure” phrase of the warning message doesn’t
add anything to help me understand the warning (it rather made me
confused). If it always has to do with missing parentheses, wouldn’t
it be better to mention that, or otherwise just remove the “make
sure” part ?
/Johan Holmberg
···
On Fri, 18 Apr 2003, Yukihiro Matsumoto wrote:
When running this this with the -w option I get the following
warning:
ex1.rb:4: warning: ambiguous first argument; make sure
make sure whether what you wrote is either
regexp as the first argument
division “str.gsub! / a”
wrap arguments with parentheses, if you don’t want to see the
warning.
I’m with you! I love poetry mode, but when it doesn’t work (increasingly
these days), you really have to cram those parens to the left, because Ruby
will still think you’re in poetry mode.
Minority or majority, though, you’re problem is that you aren’t in the
matzority.
Seriously, though, maybe it isn’t such a bad idea. Poetry mode is really
difficult to get to work properly all of the time. You have to rely a great
deal upon precedence rules, and even that is imperfect. For myself, anyway,
I find that I assume different precedence for some method calls than for
others:
puts (sin 2) - 1
sin (a + b) - 1
I tend to think of `puts’ as having lower (or is it higher? I can never
remember which is which…) precedence. Am I the only one who thinks this
way?
ex1.rb:4: warning: ambiguous first argument; make sure
make sure whether what you wrote is either
regexp as the first argument
division “str.gsub! / a”
wrap arguments with parentheses, if you don’t want to see the
warning.
Thanks for the explanation.
I feel that the “make sure” phrase of the warning message doesn’t
add anything to help me understand the warning (it rather made me
confused). If it always has to do with missing parentheses, wouldn’t
it be better to mention that, or otherwise just remove the “make
sure” part ?
Just to chime in, I’d also agree that in idiomatic English, the
“make sure” indeed tends to read like the latter part of the
warning message has gone missing or has been truncated somehow.
A couple suggestions for possibly clearer alternatives: