Project

General

Profile

Actions

Bug #12522

closed

Keyword arguments should supercede double-splat arguments

Added by gisborne (Guyren Howe) almost 8 years ago. Updated almost 8 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:76155]

Description

I propose that it is more intuitive (and much better for FREST functions; see #12521) if explicit keyword arguments supercede the double-splat argument, rather than the opposite as it is now.

This:

def foo(x:)
  p "Foo x: #{x}"
end

foo x: 1, **{x: 'fallback'}

should not print 'fallback'.

I believe that it is more intuitive for the explicit x to supercede the one in the double splat.

Ruby 2 has an amazing and under-utilized ability to sling around, pull apart and combine hashes just in the process of calling functions. I've been exploring where this can take us recently, and #12512 and this would both significantly improve the usefulness and intuitiveness of this language feature.

If we wish to retain the current behavior for compatibility or whatever, then I propose a triple splat or double-colon keyword symmetric with #12512.

Updated by nobu (Nobuyoshi Nakada) almost 8 years ago

  • Description updated (diff)
  • Status changed from Open to Rejected
foo **{x: 'fallback'}, x: 1
Actions

Also available in: Atom PDF

Like0
Like0