cactoos icon indicating copy to clipboard operation
cactoos copied to clipboard

Add a new constructor public TextOf(final Iterable<?> iterable, String delimiter)

Open tess1o opened this issue 5 years ago • 3 comments

Current TextOf has the following public constructor:

public TextOf(final Iterable<?> iterable) {
	this(
		() -> new Joined(
			", ",
			new Mapped<>(
				Object::toString,
				iterable
			)
		).asString()
	);
}

I propose to add one more constructor that accepts a delimiter:

public TextOf(final Iterable<?> iterable) {
   this(iterable, ", ");
}

public TextOf(final Iterable<?> iterable, String delimiter) {
	this(
			() -> new Joined(
					delimiter,
					new Mapped<>(
							Object::toString,
							iterable
					)
			).asString()
	);
}

I do understand that this has to be submitted as a pull request, but... :)

tess1o avatar Sep 25 '19 13:09 tess1o

@paulodamaso/z please, pay attention to this issue

0crat avatar Sep 25 '19 13:09 0crat

@tess1o/z this project will fix the problem faster if you donate a few dollars to it; just click here and pay via Stripe, it's very fast, convenient and appreciated; thanks a lot!

0crat avatar Sep 25 '19 13:09 0crat

@tess1o https://github.com/yegor256/cactoos/blob/master/src/main/java/org/cactoos/text/Joined.java already does that, right?

victornoel avatar Jul 04 '20 16:07 victornoel