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>) {
4040 fun partsFromNotation (notation : StringNotation ) = Word (parts.flatMap { it.fromNotation(notation).parts })
4141
4242 /* *
43- * Appends a part to this word.
43+ * Creates a copy of this word with the provided [part] appended .
4444 */
4545 operator fun plus (part : String ) = Word (parts + part)
4646
4747 /* *
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.
4954 */
5055 operator fun plus (word : Word ) = Word (parts + word.parts)
5156
Original file line number Diff line number Diff line change @@ -42,6 +42,8 @@ class WordTest {
4242 fun `allows to add parts` () {
4343 expect((Word (" with" ) + " more" + " parts" ))
4444 .toBe(Word (" with" , " more" , " parts" ))
45+ expect(Word (" with" ).plus(" more" , " parts" ))
46+ .toBe(Word (" with" , " more" , " parts" ))
4547 }
4648
4749 @Test
You can’t perform that action at this time.
0 commit comments