Project

General

Profile

Actions

Bug #17737

closed

`Array#permutation` does not immediately check the arity when no block is given

Added by kachick (Kenichi Kamiya) about 3 years ago. Updated over 2 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin20]
[ruby-core:102959]

Description

p [].permutation(1) #=> #<Enumerator: []:permutation(1)>
p [].permutation(1, 3) #=> #<Enumerator: []:permutation(1, 3)>
p [].permutation(1, 3).to_a #=> `permutation': wrong number of arguments (given 2, expected 0..1) (ArgumentError)
p [].cycle(1) #=> #<Enumerator: []:cycle(1)>
p [].cycle(1, 3) #=> `cycle': wrong number of arguments (given 2, expected 0..1) (ArgumentError)

Is this an intentional behavior?
I would expect To raise ArgumentError immediately if the arity is wrong like Array#cycle.

PR: https://github.com/ruby/ruby/pull/4267

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0