Feature #8371

Make some enumerators mimic arrays

Added by Ilya Vorontsov 12 months ago. Updated 11 months ago.

Assignee:Yukihiro Matsumoto
Target version:-


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'.eachchar.join("\t") and it fails just because I didn't use #toa.
I propose that enumerators have subclasses (I guess simple extending of enumerator with module can impact perfomance) such as ArrayEnumerator so that String#eachchar and #eachline and so on returned not simple Enumerator but ArrayEnumerator which will respond #join and #uniq method.


#1 Updated by Zachary Scott 11 months ago

  • Status changed from Open to Feedback
  • Assignee set to Yukihiro Matsumoto

There is a discussion on this on #1666

Also available in: Atom PDF