Actions
Bug #13647
closedSome weird behaviour with keyword arguments
Description
I was just playing around and found this weird behaviour, which seems to be in at least Ruby 2.3.0 and Ruby 2.4.0:
hashie = Hashie::Mash.new(a: :b)
def foo(hashie)
hashie.inspect
end
def woo(hashie, bashie: nil)
hashie.inspect
end
def zoo(hashie = nil, cashie: nil)
hashie.inspect
end
foo(hashie) # => "#<Hashie::Mash a=:b>"
woo(hashie) # => "#<Hashie::Mash a=:b>"
So far so good, but when we call the third method, we get this:
zoo(hashie) # => "{\"a\"=>:b}"
Similarly,
zoo(:symbol) # => ":symbol"
Is this intentional behaviour? If so, what's the rationale? If not, is it a known issue?
Actions
Like0
Like0Like0Like0Like0Like0Like0Like0