Project

General

Profile

Actions

Misc #19971

open

Confusing arity of a Proc with implicit rest parameter

Added by andrykonchin (Andrew Konchin) about 1 year ago. Updated 12 months ago.

Status:
Open
Assignee:
-
[ruby-core:115146]

Description

I've noticed that such proc proc { |a,| } has arity 1:

proc { |a,| }.arity # => 1

that means only one required parameter, but the proc behaves similar to a proc with explicit rest parameter (proc { |a, *| }) that has arity -2:

proc { |a, *| }.arity # => -2

that means one required parameter and rest parameter.

So I am wondering whether it's intentional behaviour and what the rational is behind it.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0