Closed GoogleCodeExporter closed 9 years ago
What's wrong with just passing the result of the transform() to
Lists.newArrayList or Sets.newHashSet? I think
Sets.newHashSet(Collections2.transform(set, function))
has a much clearer intent than e.g.
Sets.translate(set, function) // looking at this, I have no idea what it returns
Original comment by wasserman.louis
on 23 Aug 2012 at 5:35
Yea, that's fair.
Original comment by adam.n.g...@gmail.com
on 23 Aug 2012 at 9:21
Possibly we'll one day change transform() and friends to declare a return type
of FluentIterable. If so, this will become "Iterables.transform(...).toSet()."
http://code.google.com/p/guava-libraries/wiki/BridgeMethodInjectorOpportunities
Original comment by cpov...@google.com
on 23 Aug 2012 at 9:52
That would be very cool. Would that then still be a "live" reference to the
original collection?
Original comment by adam.n.g...@gmail.com
on 23 Aug 2012 at 10:53
The method would return ImmutableSet so that it can sever the reference.
Original comment by cpov...@google.com
on 23 Aug 2012 at 10:56
Can we mark this as WorkingAsIntended, in any case?
Original comment by wasserman.louis
on 23 Aug 2012 at 10:59
@louis. sounds good to me. thanks guys for the quick replies.
Original comment by adam.n.g...@gmail.com
on 23 Aug 2012 at 11:06
And of course even without Iterables.transform returning FluentIterable, you
can always do "FluentIterable.from(...).transform(...).toSet()". And there's
also ".copyTo(whateverCollection)" for mutable. So yeah, I think we have this
covered.
Original comment by cgdec...@gmail.com
on 23 Aug 2012 at 11:09
Original comment by cpov...@google.com
on 7 Nov 2012 at 7:41
This issue has been migrated to GitHub.
It can be found at https://github.com/google/guava/issues/<id>
Original comment by cgdecker@google.com
on 1 Nov 2014 at 4:13
Original comment by cgdecker@google.com
on 3 Nov 2014 at 9:08
Original issue reported on code.google.com by
adam.n.g...@gmail.com
on 23 Aug 2012 at 5:06