[MacRuby-devel] [ruby] #47: Cannot pass a :symbol directly as a
named parameter
ruby
ruby-noreply at macosforge.org
Mon Apr 7 16:15:46 PDT 2008
#47: Cannot pass a :symbol directly as a named parameter
----------------------------+-----------------------------------------------
Reporter: cremes at mac.com | Owner: lsansonetti at apple.com
Type: defect | Status: new
Priority: minor | Milestone: MacRuby 0.2
Component: MacRuby | Keywords: symbol named keyed parameter
----------------------------+-----------------------------------------------
Here's an example to illustrate. Code was tested against the "testing"
branch from 20080405.
class A
def initialize
@h = {}
end
def setValue(val, forKey:key)
@h[key] = val
end
end
a = A.new
a.setValue("triple", forKey::three) # fails
a.setValue("triple", forKey: :three) # succeeds
three = :three
a.setValue("triple", forKey:three) # succeeds
a.setValue("triple", forKey:'three'.to_sym) # succeeds
When using the #:: syntax the parser mistakenly views it as an attempt to
access the method #forKey on Object. At minimum it should probably throw a
more useful error message and perhaps suggest adding a space between
colons.
--
Ticket URL: <http://trac.macosforge.org/projects/ruby/ticket/47>
ruby <http://ruby.macosforge.org/>
More information about the MacRuby-devel
mailing list