I'm afraid this doesn't make sense. What if I want to send an array of symbols? I don't want them automatically turned into constants -- let alone constants from another nesting.
David Black
It would be better IMHO if methods like File.new just handled symbol options.
File.new( "foo", :rdwr, :lock, :sync )
or perhaps la Rails
File.new "foo", :options => [:rdwr, :lock, :sync]
7rans
How about "Type error: Can't convert Array into Fixnum."
(Unless you write function that accepts as flag Fixnum, Array, Hash, Kernel, Date, Pizza classes AND use constvalue to convert )
Who said that conversion is automatic? Only when you use constvalue() conversion is done. Otherwise you should use const_get
Great 7rans you should write patch (C equivalent of this)
def File.new(a,*flags)
f=0
flags.each{|flag|
case flag
f|=RDWR when :rdwr
f|=SYNC when :sync
f|=RWONLY when :rwonly
...
else
raise "misspelled flag"
}
Ondrej Bilka
David Black
It would be better IMHO if methods like File.new just handled symbol options.
or perhaps la Rails
7rans
How about "Type error: Can't convert Array into Fixnum."
(Unless you write function that accepts as flag Fixnum, Array, Hash, Kernel, Date, Pizza classes AND use constvalue to convert )
Who said that conversion is automatic? Only when you use constvalue() conversion is done. Otherwise you should use const_get
Great 7rans you should write patch (C equivalent of this) def File.new(a,*flags) f=0 flags.each{|flag| case flag f|=RDWR when :rdwr f|=SYNC when :sync f|=RWONLY when :rwonly ... else raise "misspelled flag" }
Ondrej Bilka