Feature #2832: Vector#each and Enumerable http://redmine.ruby-lang.org/issues/show/2832 Author: Marc-Andre Lafortune Status: Open, Priority: Normal Assigned to: Keiju Ishitsuka, Category: lib, Target version: 1.9.2 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]
on 2010-03-02 10:13
on 2010-03-03 08:27
Issue #2832 has been updated by Yukihiro Matsumoto. Status changed from Open to Closed % Done changed from 0 to 100 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. ---------------------------------------- http://redmine.ruby-lang.org/issues/show/2832
on 2010-03-09 05:29
Issue #2832 has been updated by Marc-Andre Lafortune. Status changed from Closed to Open 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. ---------------------------------------- http://redmine.ruby-lang.org/issues/show/2832
on 2010-03-09 06:21
Hi,
In message "Re: [ruby-core:28571] [Feature #2832](Open) 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.
on 2010-03-31 05:13
Issue #2832 has been updated by Marc-Andre Lafortune. 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, ...) ---------------------------------------- http://redmine.ruby-lang.org/issues/show/2832
on 2010-03-31 14:28
> > > 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)
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.