Project

General

Profile

Actions

Bug #13647

closed

Some weird behaviour with keyword arguments

Added by Arepo (Sasha Cooper) about 5 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
2.3.0, 2.4.0
[ruby-core:81637]

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?


Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #14183: "Real" keyword argumentClosedActions
Actions

Also available in: Atom PDF