Project

General

Profile

Actions

Bug #11048

closed

blocks raise on missing and extra keyword args

Added by bughit (bug hit) almost 9 years ago. Updated over 8 years ago.

Status:
Rejected
Target version:
-
ruby -v:
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]
[ruby-core:<unknown>]

Description

blocks intentionally tolerate arity mismatches

irb(main):001:0> proc{|a, b| [a, b]}.(1)
[
  [0] 1,
  [1] nil
]

irb(main):003:0> proc{|a, b|[a, b]}.(1, 2, 3)
[
  [0] 1,
  [1] 2
]


so why not missing keyword args?

irb(main):002:0> proc{|a:, b:|[a, b]}.(a: 1)
ArgumentError: missing keyword: b


irb(main):004:0> proc{|a:, b:|[a, b]}.(a: 1, b: 1, c: 1)
ArgumentError: unknown keyword: c

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0