Project

General

Profile

Actions

Bug #20063

closed

Inconsistent behavior with required vs optional parameters

Added by jemmai (Jemma Issroff) 5 months ago. Updated 5 months ago.

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

Description

Using repeated anonymous parameters, gives different behavior with the parameters in the same order based on whether they are required or optional.

def example_with_optional(_a = 1, _a = 2)
  _a
end

def example_with_required(_a, _a)
  _a
end

p example_with_optional # 2
p example_with_required(1, 2) # 1

It is unexpected that these two methods would return differently given the parameters are in the same order, based on whether they are optional or required.

Actions

Also available in: Atom PDF

Like0
Like1Like0Like0