Feature #2832
closedVector#each and Enumerable
Description
=begin
Vector should implement #each and include Enumerable, since it is so Array-like.
Enumerable methods that return an array should probably be specialized to return a Vector (e.g. map, first, ...)
See also [ruby-core:28403], [redmine:2831]
=end
Updated by matz (Yukihiro Matsumoto) over 14 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
=begin
This issue was solved with changeset r26801.
Marc-Andre, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
=end
Updated by marcandre (Marc-Andre Lafortune) over 14 years ago
- Status changed from Closed to Open
=begin
Thanks Matz.
Vector#map/collect should return Vector, no?
I'm fine with the others methods, like #drop(_while), #find(_all), #first, returning arrays though.
=end
Updated by matz (Yukihiro Matsumoto) over 14 years ago
=begin
Hi,
In message "Re: [ruby-core:28571] Feature #2832 Vector#each and Enumerable"
on Tue, 9 Mar 2010 13:29:03 +0900, Marc-Andre Lafortune redmine@ruby-lang.org writes:
|Vector#map/collect should return Vector, no?
I don't think so. It returns a collection of values given from the
block. Array is a representation of collection. Matrix#collect
now returns Matrix, but I consider it caused by misunderstanding.
matz.
=end
Updated by marcandre (Marc-Andre Lafortune) over 14 years ago
- Assignee changed from keiju (Keiju Ishitsuka) to marcandre (Marc-Andre Lafortune)
=begin
=end
Updated by marcandre (Marc-Andre Lafortune) over 14 years ago
=begin
I'm probably crazy, and I must be the only one wishing this, but I wish that #collect was used to collect elements (and always returned an array), while #map was used to map an object by applying a functor to its element (and returned the original class when possible, like Set, Matrix, ...)
=end
Updated by Eregon (Benoit Daloze) over 14 years ago
=begin
I'm probably crazy, and I must be the only one wishing this, but I wish
that #collect was used to collect elements (and always returned an array),
while #map was used to map an object by applying a functor to its element
(and returned the original class when possible, like Set, Matrix, ...)
I think Vector#to_a#map is better than Vector#collect, since it's far more
explicit for that purpose
I agree with the fact methods like map should return their own kind of
Enumerable (for example sorting a Hash result in ... an Array)
=end
Updated by znz (Kazuhiro NISHIYAMA) over 14 years ago
- Target version changed from 1.9.2 to 2.0.0
=begin
=end
Updated by shyouhei (Shyouhei Urabe) almost 14 years ago
- Status changed from Open to Assigned
=begin
=end
Updated by mame (Yusuke Endoh) over 11 years ago
- Target version changed from 2.0.0 to 2.6
Marc-Andre, what do we have to do about this ticket?
I'm setting to next minor. Let me know if there is any task for 2.0.0.
--
Yusuke Endoh mame@tsg.ne.jp
Updated by marcandre (Marc-Andre Lafortune) over 11 years ago
- Status changed from Assigned to Closed
Right, let's close this.
I still think that Vector#map & select be covariant, and I'll change them if ever there's a request to second that.