On Apr 28, 2012, at 1:01 AM, Rémi Forax wrote:

> Hi Jim,
> Yes, I've basically try to submit a patch each time I've written a method join
> in one of my application :)
> 
> The funny think (in fact it's even not funny) is that I think that this 
> methods
> should not be in String anymore. In Java 8, we will have defender methods
> so you can write join directly on an Iterable. And there is some discussion
> to also allow defender methods on arrays too,
> so we may can write a method join on Object[] too
> (on an interface inherited from Object[] to be precise).
> 
> I really think that list.join(",") is better than "".join(",", list) and
> ["foo", "bar"].join(",") is better than "".join(",", ["foo", "bar"]).
> but maybe I'm wrong.
> 

Good point. Although i don't see the harm with such methods on String that 
defer, or are required if say defender methods on arrays never come about.

There are also more general cases of interpose and interleave (see Clojure's 
functions as an example) since join can be implemented using interpose which 
can be implemented using interleave. Not saying join should be implemented that 
way (not so optimal for Strings only) but i think such functions are very 
useful. I am not tracking the lambda library work very closely, have such 
functions been considered?

Paul.

Reply via email to