From: meanlogin@... Date: 2014-09-25T01:44:40+00:00 Subject: [ruby-core:65266] [ruby-trunk - Bug #10293] splatting an empty hash in a method invocation sends an argument to the method (should send nothing) Issue #10293 has been updated by First Last. https://bugs.ruby-lang.org/issues/9291 is somewhat related foo(**nil) should not raise since foo(*nil) does not and it's the more useful behavior ---------------------------------------- Bug #10293: splatting an empty hash in a method invocation sends an argument to the method (should send nothing) https://bugs.ruby-lang.org/issues/10293#change-49091 * Author: First Last * Status: Assigned * Priority: Normal * Assignee: Nobuyoshi Nakada * Category: core * Target version: current: 2.2.0 * ruby -v: ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-linux] * Backport: 2.0.0: UNKNOWN, 2.1: REQUIRED ---------------------------------------- irb(main):001:0> def foo; end; foo **{} ArgumentError: wrong number of arguments (1 for 0) note that splatting an empty array results in no arguments this behavior is particularly problematic with send (dispatching to different methods) send method_name, *possibly_empty_arg_list, **possibly_empty_keyarg_hash one should not have to do if possibly_empty_keyarg_hash.empty? receiver.send method_name, *possibly_empty_arg_list else receiver.send method_name, *possibly_empty_arg_list, **possibly_empty_keyarg_hash end or possibly_empty_arg_list << possibly_empty_keyarg_hash unless possibly_empty_keyarg_hash.empty? receiver.send method_name, *possibly_empty_arg_list -- https://bugs.ruby-lang.org/