Project

General

Profile

Feature #8371

Make some enumerators mimic arrays

Added by prijutme4ty (Ilya Vorontsov) about 4 years ago. Updated about 4 years ago.

Status:
Feedback
Priority:
Normal
Target version:
-
[ruby-core:54809]

Description

Some enumerators yields data by one element so that in some way such enumerators can be treated as arrays in some ways. But they are still enumerators, so they doesn't respond to methods each array responds. As an example, there is code I write from time to time:
'Hello world'.each_char.join("\t") and it fails just because I didn't use #to_a.
I propose that enumerators have subclasses (I guess simple extending of enumerator with module can impact perfomance) such as ArrayEnumerator so that String#each_char and #each_line and so on returned not simple Enumerator but ArrayEnumerator which will respond #join and #uniq method.

History

#1 [ruby-core:55241] Updated by zzak (Zachary Scott) about 4 years ago

  • Status changed from Open to Feedback
  • Assignee set to matz (Yukihiro Matsumoto)

There is a discussion on this on #1666

Also available in: Atom PDF