When I write code that does this:
class Foo
def self.[](name, *args)
p name, args
end
X = self
_ = 1
foo =
[ :x, :y, :z, :a, :b ]
X[ :foo, _, _, _, _, _ ]
X[ :foo, _, _, _, _, _ ]
end
Then I get output like this:
[pbrannan@zaphod tmp]$ !ritten
ruby -w bracket.rb
bracket.rb:11: warning: useless use of [] in void context
:foo
[1, 1, 1, 1, 1]
:foo
[1, 1, 1, 1, 1]
However, if I take out the second X[ :foo, ... ] line, then I do not get
the warning.
I'm doing this because it is convenient to specify a table of data this
way.
1) Why do I get this warning?
2) Is this a bug?
3) Is there a workaround until this can be fixed (or if it will be fixed)?
Paul