Project

General

Profile

This project is closed and read-only.

Actions

Backport #2946

closed

Apparently inconsistent zip of Range

Backport #2946: Apparently inconsistent zip of Range

Added by candlerb (Brian Candler) over 16 years ago. Updated about 7 years ago.

Status:
Closed
Assignee:
-
[ruby-core:28559]

Description

=begin
You can zip an Array onto a Range, but not a Range onto an Array.

RUBY_DESCRIPTION
=> "ruby 1.8.7 (2009-06-12 patchlevel 174) [x86_64-linux]"

(9..12).zip([1,2,3,4])
=> [[9, 1], [10, 2], [11, 3], [12, 4]]

[1,2,3,4].zip(5..8)
TypeError: can't convert Range into Array
from (irb):6:in `zip'
from (irb):6
from :0

Wonder if zip should call #to_a on its argument?

(5..8).to_a
=> [5, 6, 7, 8]
=end

Updated by jeremyevans0 (Jeremy Evans) about 7 years ago Actions #1

  • Tracker changed from Feature to Backport
  • Project changed from 2 to 5
  • Description updated (diff)
  • Status changed from Open to Closed
Actions

Also available in: PDF Atom