Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method reverse() to List #2804

Closed
DartBot opened this issue Apr 29, 2012 · 11 comments
Closed

Add method reverse() to List #2804

DartBot opened this issue Apr 29, 2012 · 11 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-collection type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Apr 29, 2012

This issue was originally filed by @pjako


It would be nice to have a method on Lists to reverse them...

print([1,2,3].reverse());

out:
3 2 1

@dgrove
Copy link
Contributor

dgrove commented Apr 29, 2012

Removed Type-Defect label.
Added Type-Enhancement, Area-Library, Triaged labels.

@sethladd
Copy link
Contributor

Added Library-Collections label.

@alan-knight
Copy link
Contributor

I note that this is polyfilled in internationalization, which should be removed once this is available.

@DartBot
Copy link
Author

DartBot commented Aug 8, 2012

This comment was originally written by @seaneagan


As mentioned in issue #1305, I think this method should return a view (wrapper) on the original List, rather than copying each element into a brand new List. Also, "reverse" has a mutative connotation. I think it would be better as a getter, some options for the name are:

"reversed"
"inReverse"
"backwards"

In the case where one does want to copy the elements into a brand new List, they could do the following:

var reversedCopy = new List.from(list.reversed);

@alan-knight
Copy link
Contributor

I agree that reversed is better for something that returns either a copy or a wrapper.

@munificent
Copy link
Member

Issue #5728 has been merged into this issue.

@DartBot
Copy link
Author

DartBot commented Oct 31, 2012

This comment was originally written by jjinux...@google.com


It'd be great if we had a unicode-aware reverse method on String as well.

@dgrove
Copy link
Contributor

dgrove commented Jan 11, 2013

Removed Library-Collections label.
Added Library-Collection label.

@rakudrama
Copy link
Member

Just last week I wanted a mutating reverse of a subrange of a list.

For example, you can exchange two adjacent blocks [start, middle) and [middle,end) like this:

list.reverse(start, end);
list.reverse(start, middle);
list.reverse(middle, end);

@alan-knight
Copy link
Contributor

There is now a reversed() method on List. Should this be closed?


cc @floitschG.
cc @lrhn.

@lrhn
Copy link
Member

lrhn commented Aug 26, 2013

Closing as fixed.
The original request has been fulfilled (even if its not mutating).

If there is a need for a mutating "reverse" method, it should be filed as a separate feature request.


Added Fixed label.

@DartBot DartBot added Type-Enhancement area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-collection labels Aug 26, 2013
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed type-enhancement labels Mar 1, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-collection type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

8 participants