Skip to content

Commit d3c6d29

Browse files
kschuetzjnape
authored andcommitted
Improve docs for Intersperse (palatable#54)
1 parent 65b0e30 commit d3c6d29

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/main/java/com/jnape/palatable/lambda/functions/builtin/fn2/Intersperse.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import static com.jnape.palatable.lambda.functions.builtin.fn2.PrependAll.prependAll;
88

99
/**
10-
* Lazily inject the provided separator value between each value in the supplied <code>Iterable</code>. An empty
11-
* <code>Iterable</code> is left untouched.
10+
* Lazily inject the provided separator value between each value in the supplied <code>Iterable</code>. An
11+
* <code>Iterable</code> with fewer than two elements is left untouched.
1212
*
1313
* @param <A> the Iterable parameter type
1414
* @see PrependAll

src/test/java/com/jnape/palatable/lambda/functions/builtin/fn2/IntersperseTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ public void interspersesBetweenElementsInIterable() {
3030
assertThat(intersperse(0, asList(1, 2, 3)), iterates(1, 0, 2, 0, 3));
3131
}
3232

33+
@Test
34+
public void doesNotIntersperseSingletonIterable() {
35+
assertThat(intersperse(0, asList(1)), iterates(1));
36+
}
37+
3338
@Test
3439
public void doesNotIntersperseEmptyIterable() {
3540
assertThat(intersperse(0, emptyList()), isEmpty());

0 commit comments

Comments
 (0)