I have a code:

module Foo
  class Config
    attr_reader :config

    def initialize
      @config = {}  <-- standard hash
    end

    def <<(key, val)   <-- I want to implement "<<" sign as a method
name
      n_hash = {key => val}
      if (@config.merge!(n_hash))
        return true
      else
        return false
      end
    end

  end
end



Now I call it:

c = Foo::Config.new

c << "name", "value"   <- This doesn't work. ...syntax error, unexpected
',', expecting ')'

c.<<("name", "value")  <- this works. But it's ridiculous such a call in
Ruby.

Why
c << "name", "value"
doesn't work?

-- 
Posted via http://www.ruby-forum.com/.