File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -40,12 +40,17 @@ class Word(val parts: Sequence<String>) {
40
40
fun partsFromNotation (notation : StringNotation ) = Word (parts.flatMap { it.fromNotation(notation).parts })
41
41
42
42
/* *
43
- * Appends a part to this word.
43
+ * Creates a copy of this word with the provided [part] appended .
44
44
*/
45
45
operator fun plus (part : String ) = Word (parts + part)
46
46
47
47
/* *
48
- * Appends all parts of the given [word] to this word.
48
+ * Creates a copy of this word with all provided [parts] appended.
49
+ */
50
+ fun plus (vararg parts : String ) = Word (this .parts + parts)
51
+
52
+ /* *
53
+ * Creates a copy of this word with all parts of the provided [word] appended.
49
54
*/
50
55
operator fun plus (word : Word ) = Word (parts + word.parts)
51
56
Original file line number Diff line number Diff line change @@ -42,6 +42,8 @@ class WordTest {
42
42
fun `allows to add parts` () {
43
43
expect((Word (" with" ) + " more" + " parts" ))
44
44
.toBe(Word (" with" , " more" , " parts" ))
45
+ expect(Word (" with" ).plus(" more" , " parts" ))
46
+ .toBe(Word (" with" , " more" , " parts" ))
45
47
}
46
48
47
49
@Test
You can’t perform that action at this time.
0 commit comments