Issue #13336 has been updated by mame (Yusuke Endoh).


This is intended.  If a method accepts keyword arguments and if its last argument is a hash object, it is considered for keyword arguments.  If you want to pass a hash as the first parameter, you need to explicitly pass a hash for keyword arguments, i.e., `funny({k: 1}, {})`.


----------------------------------------
Bug #13336: Default Parameters don't work
https://bugs.ruby-lang.org/issues/13336#change-64959

* Author: herbert.bonaffini / gmail.com (Herbert Bonaffini)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 2.3.1
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
```ruby
def funny(a = true, b: nil)
  p a
end

funny([1,2,3]) # => [1,2,3]

funny({k:1}) # => in `funny': unknown keyword: k (ArgumentError)
```

---Files--------------------------------
hello_bug.rb (132 Bytes)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>