Project

General

Profile

Actions

Feature #15747

closed

`(..1).last(2)` should return array but raise TypeError

Added by wanabe (_ wanabe) about 5 years ago. Updated over 4 years ago.

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

Description

Range#last with argument for beginless range shouldn't raise exception, should it?

$ ./miniruby -ve 'p (..1).last(2)'
ruby 2.7.0dev (2019-04-04 trunk 67430) [x86_64-linux]
Traceback (most recent call last):
	4: from -e:1:in `<main>'
	3: from -e:1:in `last'
	2: from -e:1:in `to_a'
	1: from -e:1:in `to_a'
-e:1:in `each': can't iterate from NilClass (TypeError)

Range#last without argument works fine.

$ ./miniruby -ve 'p (..1).last'
ruby 2.7.0dev (2019-04-04 trunk 67430) [x86_64-linux]
1
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0