Project

General

Profile

Actions

Bug #15174

closed

Sorting array of elements using "&:size" block, in which more than 1 element

Added by Mr_Cartoon (Mr Cartoon) over 5 years ago. Updated over 5 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
2.5.1, 2.6.0-preview2
[ruby-core:89209]

Description

Example with ranges(first with what defined bug), but also tested on strings, symbols, integers
Good

[1..2].sort { |x| x.size }
[1..2, 4..5].sort { |x| x.size }
[1..2].sort(&:size)

Bad

[1..2, 4..5].sort(&:size)

Traceback (most recent call last):
4: from /home/sviat/.rvm/rubies/ruby-2.6.0-preview2/bin/irb:11:in <main>' 3: from (irb):3 2: from (irb):3:in sort'
1: from (irb):3:in `size'
ArgumentError (wrong number of arguments (given 1, expected 0))

Tested ruby versions: 2.5.1, 2.6.0-preview2

Actions

Also available in: Atom PDF

Like0
Like0Like0