From fcc6d323edbf695d9c71d191e6109e8ce30ac94a Mon Sep 17 00:00:00 2001 From: Colin Leach Date: Sat, 30 Aug 2025 16:37:56 -0700 Subject: [PATCH 1/4] Add Strings concept --- concepts/strings/.meta/config.json | 7 ++ concepts/strings/about.md | 148 +++++++++++++++++++++++++++++ concepts/strings/introduction.md | 97 +++++++++++++++++++ concepts/strings/links.json | 14 +++ config.json | 5 + 5 files changed, 271 insertions(+) create mode 100644 concepts/strings/.meta/config.json create mode 100644 concepts/strings/about.md create mode 100644 concepts/strings/introduction.md create mode 100644 concepts/strings/links.json diff --git a/concepts/strings/.meta/config.json b/concepts/strings/.meta/config.json new file mode 100644 index 00000000..cf210f8c --- /dev/null +++ b/concepts/strings/.meta/config.json @@ -0,0 +1,7 @@ +{ + "authors": [ + "colinleach" + ], + "contributors": [], + "blurb": "Strings are an immutable sequence of Unicode characters." +} diff --git a/concepts/strings/about.md b/concepts/strings/about.md new file mode 100644 index 00000000..dc58f2d7 --- /dev/null +++ b/concepts/strings/about.md @@ -0,0 +1,148 @@ +# About Strings + +A [`string`][string] in Kotlin is an immutable sequence of Unicode characters. + +[`Immutable`][immutable] means that any operation on a string must return a new string: the original string can never change. + +[`Unicode`][unicode] means that most of the world's writing systems can be represented, but (in contrast to older languages such as C) there is no 1:1 mapping between characters and bytes. +This will be discussed further in the [`Chars`][chars] Concept. + +A string is surrounded by double-quotes `" "`. + +Some characters need escaping: `\'`, `\\`, plus the usual non-printing characters such as `\t` (tab) and `\n` (newline). + +```kotlin +val s = "Escape apostrophe \' and backslash \\." +// Escape apostrophe ' and backslash \. +``` + +Raw strings use 3 double-quotes, and can contain arbitrary text (no need for escaping). +Multiline strings are also supported, including flexible handling of indents. + +```kotlin +val multi = """I'm a + |multi-line + |string with special characters \ \t """ + +multi.trimMargin() // delimiter defaults to | but can be specified +//I'm a +//multi-line +//string with special characters \ \t +``` + +Strings can be concatenated with `+`, but this is best limited to short and simple cases. +There are other and often better options. + +## String templates + +[`Templates`][templates] refers to what some other languages call "interpolation". + +if a dollar sign `$` is followed by an identifier or expression within a string, the _value_ is substituted. + +```kotlin +val x = 42 +val st = "x is $x, x squared is ${x * x}" +// x is 42, x squared is 1764 +``` + +The braces `{ }` are needed around expressions when parsing would otherwise be ambiguous. + +## String formatting + +On the JVM platform (only), `String.format()` allows more precise formatting than string templates, with [syntax][formats] similar to the (_very old!_) [`printf`][printf] functions. + +```kotlin +String.format("%s %.3f", "π ≈", 3.14159) +//π ≈ 3.142 +``` + +## String functions + +Kotlin provides _many_ [`functions`][string-functions] to manipulate strings. + +Mostly, these are [`extensions functions`][extensions] rather than members of the `String` class, though this has little effect on how we use them. + +***Note:*** _Kotlin's rather complex [documentation][string-functions] pages hide extension functions in the default view. +Be sure to click `Members and Extensions` to expand this section._ + +The following example shows just a small selection of what is available: + +```kotlin +val str = "Hello World!" + +str.length // => 12 (a property, not a function) +str.elementAt(6) // => W +str.elementAtOrNull(20) // => null (index out of range) +str.substring(6, 11) // => "World" + +str.lowercase() // => "hello world!" +str.uppercase() // => "HELLO WORLD!" + +str.startsWith("Hel") // => true +str.endsWith("xyz") // => false + +str.toCharArray() // => [H, e, l, l, o, , W, o, r, l, d, !] +"42".toInt() + 1 // => 43 (parsing; see also toFloat) +``` + +## Building a string + +Sometimes a long string needs to be built up in stages, for example within a loop. + +Concatenating strings with `+` soon becomes neither elegant nor performant: immutability means that there is a _lot_ of copying required. + +Kotlin has various more efficient ways to combine multiple string: + +- String templates, described above. +- [`joinToString()][jointostring], which will be covered in the [Lists][lists] Concept. +- Java's [`StringBuilder`][stringbuilder], which is not regarded as particularly idiomatic Kotlin. +- Kotlin's [`buildString()`][buildstring], which wraps `StringBuilder` in a more concise and idiomatic syntax. +This takes string-building logic as a lambda argument, which will be discussed in a later Concept. + +In essence, a `StringBuilder` is a list-like structure, with many convenient methods. +This is a small selection: + +- [`append()`][sb-append] to add to the end. +- [`insert()`][sb-insert] to add at a specified position. +- [`deleteAt()`][sb-deleteat] and [`deleteRange()`][sb-deleterange] to remove from specified position(s). +- `toString()` to convert to a normal string at the end: concatenating everything in a single, performant operation. + +```kotlin +// Available, not recommended +val sb = StringBuilder() +sb.append("Hello ") +sb.append("World!") +sb.toString() +//Hello World! +``` + +A `buildString()` example, using syntax from later Concepts: + +```kotlin +val countDown = buildString { + for (i in 5 downTo 1) { + append(i) + append("_") + } +} +// countDown is "5_4_3_2_1_" +``` + + +[string]: https://kotlinlang.org/docs/strings.html +[immutable]: https://en.wikipedia.org/wiki/Immutable_object +[unicode]: https://en.wikipedia.org/wiki/Unicode +[formats]: https://docs.oracle.com/javase/8/docs/api/java/util/Formatter.html#summary +[printf]: https://en.wikipedia.org/wiki/Printf +[stringbuilder]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.text/-string-builder/ +[extensions]: https://kotlinlang.org/docs/extensions.html#extensions.md +[string-functions]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/ +[chars]: https://exercism.org/tracks/kotlin/concepts/chars +[lists]: https://exercism.org/tracks/kotlin/concepts/lists +[templates]: https://kotlinlang.org/docs/strings.html#string-templates +[sb-append]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.text/-string-builder/#9100522%2FFunctions%2F-705004581 +[sb-insert]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.text/-string-builder/#-132863384%2FFunctions%2F-705004581 +[sb-deleteat]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.text/-string-builder/#-386007892%2FFunctions%2F-956074838 +[sb-deleterange]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.text/-string-builder/#-1622040372%2FFunctions%2F-956074838 +[buildstring]: https://kotlinlang.org/docs/java-to-kotlin-idioms-strings.html#build-a-string +[jointostring]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/join-to-string.html diff --git a/concepts/strings/introduction.md b/concepts/strings/introduction.md new file mode 100644 index 00000000..9d2eff08 --- /dev/null +++ b/concepts/strings/introduction.md @@ -0,0 +1,97 @@ +# Introduction + +A [`string`][string] in Kotlin is an immutable sequence of Unicode characters. + +[`Immutable`][immutable] means that any operation on a string must return a new string: the original string can never change. + +[`Unicode`][unicode] means that most of the world's writing systems can be represented, but (in contrast to older languages such as C) there is no 1:1 mapping between characters and bytes. + +A string is usually surrounded by double-quotes `" "`. + +Some characters need escaping: `\'`, `\\`, plus the usual non-printing characters such as `\t` (tab) and `\n` (newline). + +```kotlin +val s = "Escape apostrophe \' and backslash \\." +// Escape apostrophe ' and backslash \. +``` + +Raw strings use 3 double-quotes, and can contain arbitrary text (no need for escaping). +Multiline strings are also supported, including flexible handling of indents. + +```kotlin +val multi = """I'm a + |multi-line + |string with special characters \ \t """ + +multi.trimMargin() // delimiter defaults to | but can be specified +//I'm a +//multi-line +//string with special characters \ \t +``` + +Strings can be concatenated with `+`, but this is best limited to short and simple cases. +There are other and often better options. + +## String templates + +This refers to what some other languages call "interpolation". + +if a dollar sign `$` is followed by an identifier or expression within a string, the _value_ is substituted. + +```kotlin +val x = 42 +val st = "x is $x, x squared is ${x * x}" +// x is 42, x squared is 1764 +``` + +The braces `{ }` are needed around expressions when parsing would otherwise be ambiguous. + +In general, use of string templates is a more efficient and idiomatic way to combine strings than using `+`. + +## String formatting + +On the JVM platform, `String.format()` allows more precise formatting than string templates, with [syntax][formats] similar to the (_very old!_) [`printf`][printf] functions. + +```kotlin +String.format("%s %.3f", "π ≈", 3.14159) +//π ≈ 3.142 +``` + +## String functions + +Kotlin provides _many_ [`functions`][string-functions] to manipulate strings. + +Mostly, these are [`extensions functions`][extensions] rather than members of the `String` class, though this has little effect on how we use them. + +***Note:*** _Kotlin's rather complex [documentation][string-functions] pages hide extension functions in the default view. +Be sure to click `Members and Extensions` to expand this section._ + +The following example shows just a small selection of what is available: + +```kotlin +val str = "Hello World!" + +str.length // => 12 (a property, not a function) +str.elementAt(6) // => W +str.elementAtOrNull(20) // => null (index out of range) +str.substring(6, 11) // => "World" + +str.lowercase() // => "hello world!" +str.uppercase() // => "HELLO WORLD!" + +str.startsWith("Hel") // => true +str.endsWith("xyz") // => false + +str.toCharArray() // => [H, e, l, l, o, , W, o, r, l, d, !] +"42".toInt() + 1 // => 43 (parsing; see also toFloat) +``` + + +[string]: https://kotlinlang.org/docs/strings.html +[immutable]: https://en.wikipedia.org/wiki/Immutable_object +[unicode]: https://en.wikipedia.org/wiki/Unicode +[formats]: https://docs.oracle.com/javase/8/docs/api/java/util/Formatter.html#summary +[printf]: https://en.wikipedia.org/wiki/Printf +[stringbuilder]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.text/-string-builder/ +[extensions]: https://kotlinlang.org/docs/extensions.html#extensions.md +[string-functions]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/ diff --git a/concepts/strings/links.json b/concepts/strings/links.json new file mode 100644 index 00000000..32b6b89a --- /dev/null +++ b/concepts/strings/links.json @@ -0,0 +1,14 @@ +[ + { + "url": "https://kotlinlang.org/docs/strings.html", + "description": "Kotlin string introduction" + }, + { + "url": "https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/", + "description": "String functions" + }, + { + "url": "https://kotlinlang.org/docs/strings.html#string-templates", + "description": "String Templates" + } +] diff --git a/config.json b/config.json index ba7a0c1d..0f44a742 100644 --- a/config.json +++ b/config.json @@ -1383,6 +1383,11 @@ "slug": "booleans", "name": "Booleans" }, + { + "uuid": "157bbe3b-e4f5-41f7-8e0e-e2f57d526617", + "slug": "strings", + "name": "Strings" + }, { "uuid": "168827c0-4867-449a-ad22-611c87314c48", "slug": "conditionals", From 913ac2afd2a1c406d0d52a5bfda072316c402017 Mon Sep 17 00:00:00 2001 From: Colin Leach Date: Sun, 31 Aug 2025 09:32:39 -0700 Subject: [PATCH 2/4] response to reviewer comments --- concepts/strings/about.md | 84 +++++++++++++++++--------------- concepts/strings/introduction.md | 39 ++++++--------- 2 files changed, 59 insertions(+), 64 deletions(-) diff --git a/concepts/strings/about.md b/concepts/strings/about.md index dc58f2d7..fe9867f1 100644 --- a/concepts/strings/about.md +++ b/concepts/strings/about.md @@ -1,19 +1,19 @@ # About Strings -A [`string`][string] in Kotlin is an immutable sequence of Unicode characters. +A [`string`][ref-string] in Kotlin is an immutable sequence of Unicode characters. -[`Immutable`][immutable] means that any operation on a string must return a new string: the original string can never change. +[`Immutable`][wiki-immutable] means that any operation on a string must return a new string: the original string can never change. -[`Unicode`][unicode] means that most of the world's writing systems can be represented, but (in contrast to older languages such as C) there is no 1:1 mapping between characters and bytes. -This will be discussed further in the [`Chars`][chars] Concept. +[`Unicode`][wiki-unicode] means that most of the world's writing systems can be represented, but (in contrast to older languages such as C) there is no 1:1 mapping between characters and bytes. +This will be discussed further in the [`Chars`][concept-chars] Concept. A string is surrounded by double-quotes `" "`. -Some characters need escaping: `\'`, `\\`, plus the usual non-printing characters such as `\t` (tab) and `\n` (newline). +Some characters need escaping: `\\`, plus the usual non-printing characters such as `\t` (tab) and `\n` (newline). ```kotlin -val s = "Escape apostrophe \' and backslash \\." -// Escape apostrophe ' and backslash \. +val s = "Escape backslash \\." +// Escape backslash \. ``` Raw strings use 3 double-quotes, and can contain arbitrary text (no need for escaping). @@ -35,34 +35,40 @@ There are other and often better options. ## String templates -[`Templates`][templates] refers to what some other languages call "interpolation". +[`Templates`][ref-templates] refers to what some other languages call "interpolation". -if a dollar sign `$` is followed by an identifier or expression within a string, the _value_ is substituted. +If a string contains a dollar sign `$`, followed by an identifier, or contains braces (`{expression}`) surrounding an expression, those are substituted by respectively the value or the result of the expression. ```kotlin val x = 42 -val st = "x is $x, x squared is ${x * x}" +val st = "x is $x, x squared is {x * x}" // x is 42, x squared is 1764 ``` -The braces `{ }` are needed around expressions when parsing would otherwise be ambiguous. - ## String formatting -On the JVM platform (only), `String.format()` allows more precise formatting than string templates, with [syntax][formats] similar to the (_very old!_) [`printf`][printf] functions. +On the JVM platform (only), `String.format()` allows more precise formatting than string templates, with [syntax][web-formats] similar to the (_very old!_) [`printf`][wiki-printf] functions. ```kotlin String.format("%s %.3f", "π ≈", 3.14159) //π ≈ 3.142 ``` +~~~~exercism/advanced +Kotlin can be compiled to several different targets: the Java Virtual Machine, JavaScript, native binaries for Linux, Windows, Android and Apple, plus two variants of WebAssembly. + +Essentially the same code can be used for each, but different capabilities in the target platforms mean some differences in which standard library functions are supported. + +Exercism currently uses the JVM for testing. +~~~~ + ## String functions -Kotlin provides _many_ [`functions`][string-functions] to manipulate strings. +Kotlin provides _many_ [`functions`][ref-string-functions] to manipulate strings. -Mostly, these are [`extensions functions`][extensions] rather than members of the `String` class, though this has little effect on how we use them. +Mostly, these are [`extensions functions`][ref-extensions] rather than members of the `String` class, though this has little effect on how we use them. -***Note:*** _Kotlin's rather complex [documentation][string-functions] pages hide extension functions in the default view. +***Note:*** _Kotlin's rather complex [documentation][ref-string-functions] pages hide extension functions in the default view. Be sure to click `Members and Extensions` to expand this section._ The following example shows just a small selection of what is available: @@ -94,17 +100,17 @@ Concatenating strings with `+` soon becomes neither elegant nor performant: immu Kotlin has various more efficient ways to combine multiple string: - String templates, described above. -- [`joinToString()][jointostring], which will be covered in the [Lists][lists] Concept. -- Java's [`StringBuilder`][stringbuilder], which is not regarded as particularly idiomatic Kotlin. -- Kotlin's [`buildString()`][buildstring], which wraps `StringBuilder` in a more concise and idiomatic syntax. +- [`joinToString()][ref-jointostring], which will be covered in the [Lists][concept-lists] Concept. +- Java's [`StringBuilder`][ref-stringbuilder], which is not regarded as particularly idiomatic Kotlin. +- Kotlin's [`buildString()`][ref-buildstring], which wraps `StringBuilder` in a more concise and idiomatic syntax. This takes string-building logic as a lambda argument, which will be discussed in a later Concept. In essence, a `StringBuilder` is a list-like structure, with many convenient methods. This is a small selection: -- [`append()`][sb-append] to add to the end. -- [`insert()`][sb-insert] to add at a specified position. -- [`deleteAt()`][sb-deleteat] and [`deleteRange()`][sb-deleterange] to remove from specified position(s). +- [`append()`][ref-sb-append] to add to the end. +- [`insert()`][ref-sb-insert] to add at a specified position. +- [`deleteAt()`][ref-sb-deleteat] and [`deleteRange()`][ref-sb-deleterange] to remove from specified position(s). - `toString()` to convert to a normal string at the end: concatenating everything in a single, performant operation. ```kotlin @@ -129,20 +135,20 @@ val countDown = buildString { ``` -[string]: https://kotlinlang.org/docs/strings.html -[immutable]: https://en.wikipedia.org/wiki/Immutable_object -[unicode]: https://en.wikipedia.org/wiki/Unicode -[formats]: https://docs.oracle.com/javase/8/docs/api/java/util/Formatter.html#summary -[printf]: https://en.wikipedia.org/wiki/Printf -[stringbuilder]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.text/-string-builder/ -[extensions]: https://kotlinlang.org/docs/extensions.html#extensions.md -[string-functions]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/ -[chars]: https://exercism.org/tracks/kotlin/concepts/chars -[lists]: https://exercism.org/tracks/kotlin/concepts/lists -[templates]: https://kotlinlang.org/docs/strings.html#string-templates -[sb-append]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.text/-string-builder/#9100522%2FFunctions%2F-705004581 -[sb-insert]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.text/-string-builder/#-132863384%2FFunctions%2F-705004581 -[sb-deleteat]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.text/-string-builder/#-386007892%2FFunctions%2F-956074838 -[sb-deleterange]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.text/-string-builder/#-1622040372%2FFunctions%2F-956074838 -[buildstring]: https://kotlinlang.org/docs/java-to-kotlin-idioms-strings.html#build-a-string -[jointostring]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/join-to-string.html +[ref-string]: https://kotlinlang.org/docs/strings.html +[wiki-immutable]: https://en.wikipedia.org/wiki/Immutable_object +[wiki-unicode]: https://en.wikipedia.org/wiki/Unicode +[web-formats]: https://docs.oracle.com/javase/8/docs/api/java/util/Formatter.html#summary +[wiki-printf]: https://en.wikipedia.org/wiki/Printf +[ref-stringbuilder]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.text/-string-builder/ +[ref-extensions]: https://kotlinlang.org/docs/extensions.html#extensions.md +[ref-string-functions]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/ +[concept-chars]: https://exercism.org/tracks/kotlin/concepts/chars +[concept-lists]: https://exercism.org/tracks/kotlin/concepts/lists +[ref-templates]: https://kotlinlang.org/docs/strings.html#string-templates +[ref-sb-append]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.text/-string-builder/#9100522%2FFunctions%2F-705004581 +[ref-sb-insert]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.text/-string-builder/#-132863384%2FFunctions%2F-705004581 +[ref-sb-deleteat]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.text/-string-builder/#-386007892%2FFunctions%2F-956074838 +[ref-sb-deleterange]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.text/-string-builder/#-1622040372%2FFunctions%2F-956074838 +[ref-buildstring]: https://kotlinlang.org/docs/java-to-kotlin-idioms-strings.html#build-a-string +[ref-jointostring]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/join-to-string.html diff --git a/concepts/strings/introduction.md b/concepts/strings/introduction.md index 9d2eff08..30689fc6 100644 --- a/concepts/strings/introduction.md +++ b/concepts/strings/introduction.md @@ -1,10 +1,10 @@ # Introduction -A [`string`][string] in Kotlin is an immutable sequence of Unicode characters. +A [`string`][ref-string] in Kotlin is an immutable sequence of Unicode characters. -[`Immutable`][immutable] means that any operation on a string must return a new string: the original string can never change. +[`Immutable`][wiki-immutable] means that any operation on a string must return a new string: the original string can never change. -[`Unicode`][unicode] means that most of the world's writing systems can be represented, but (in contrast to older languages such as C) there is no 1:1 mapping between characters and bytes. +[`Unicode`][wiki-unicode] means that most of the world's writing systems can be represented, but (in contrast to older languages such as C) there is no 1:1 mapping between characters and bytes. A string is usually surrounded by double-quotes `" "`. @@ -36,11 +36,11 @@ There are other and often better options. This refers to what some other languages call "interpolation". -if a dollar sign `$` is followed by an identifier or expression within a string, the _value_ is substituted. +If a string contains a dollar sign `$`, followed by an identifier, or contains braces (`{expression}`) surrounding an expression, those are substituted by respectively the value or the result of the expression. ```kotlin val x = 42 -val st = "x is $x, x squared is ${x * x}" +val st = "x is $x, x squared is {x * x}" // x is 42, x squared is 1764 ``` @@ -48,22 +48,13 @@ The braces `{ }` are needed around expressions when parsing would otherwise be a In general, use of string templates is a more efficient and idiomatic way to combine strings than using `+`. -## String formatting - -On the JVM platform, `String.format()` allows more precise formatting than string templates, with [syntax][formats] similar to the (_very old!_) [`printf`][printf] functions. - -```kotlin -String.format("%s %.3f", "π ≈", 3.14159) -//π ≈ 3.142 -``` - ## String functions -Kotlin provides _many_ [`functions`][string-functions] to manipulate strings. +Kotlin provides _many_ [`functions`][ref-string-functions] to manipulate strings. -Mostly, these are [`extensions functions`][extensions] rather than members of the `String` class, though this has little effect on how we use them. +Mostly, these are [`extensions functions`][ref-extensions] rather than members of the `String` class, though this has little effect on how we use them. -***Note:*** _Kotlin's rather complex [documentation][string-functions] pages hide extension functions in the default view. +***Note:*** _Kotlin's rather complex [documentation][ref-string-functions] pages hide extension functions in the default view. Be sure to click `Members and Extensions` to expand this section._ The following example shows just a small selection of what is available: @@ -87,11 +78,9 @@ str.toCharArray() // => [H, e, l, l, o, , W, o, r, l, d, !] ``` -[string]: https://kotlinlang.org/docs/strings.html -[immutable]: https://en.wikipedia.org/wiki/Immutable_object -[unicode]: https://en.wikipedia.org/wiki/Unicode -[formats]: https://docs.oracle.com/javase/8/docs/api/java/util/Formatter.html#summary -[printf]: https://en.wikipedia.org/wiki/Printf -[stringbuilder]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.text/-string-builder/ -[extensions]: https://kotlinlang.org/docs/extensions.html#extensions.md -[string-functions]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/ +[ref-string]: https://kotlinlang.org/docs/strings.html +[wiki-immutable]: https://en.wikipedia.org/wiki/Immutable_object +[wiki-unicode]: https://en.wikipedia.org/wiki/Unicode +[ref-stringbuilder]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.text/-string-builder/ +[ref-extensions]: https://kotlinlang.org/docs/extensions.html#extensions.md +[ref-string-functions]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/ From c5f0a7b5c2c7c3e91d34599294590038e21b2b37 Mon Sep 17 00:00:00 2001 From: Colin Leach Date: Sun, 31 Aug 2025 10:43:45 -0700 Subject: [PATCH 3/4] note moved to admonition block --- concepts/strings/about.md | 8 ++++++-- concepts/strings/introduction.md | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/concepts/strings/about.md b/concepts/strings/about.md index fe9867f1..72806268 100644 --- a/concepts/strings/about.md +++ b/concepts/strings/about.md @@ -68,8 +68,12 @@ Kotlin provides _many_ [`functions`][ref-string-functions] to manipulate strings Mostly, these are [`extensions functions`][ref-extensions] rather than members of the `String` class, though this has little effect on how we use them. -***Note:*** _Kotlin's rather complex [documentation][ref-string-functions] pages hide extension functions in the default view. -Be sure to click `Members and Extensions` to expand this section._ +~~~~exercism/note +Kotlin's rather complex [documentation][ref-string-functions] pages hide extension functions in the default view. +Be sure to click `Members and Extensions` to expand this section. + +[ref-string-functions]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/ +~~~~ The following example shows just a small selection of what is available: diff --git a/concepts/strings/introduction.md b/concepts/strings/introduction.md index 30689fc6..88d55e1c 100644 --- a/concepts/strings/introduction.md +++ b/concepts/strings/introduction.md @@ -54,8 +54,12 @@ Kotlin provides _many_ [`functions`][ref-string-functions] to manipulate strings Mostly, these are [`extensions functions`][ref-extensions] rather than members of the `String` class, though this has little effect on how we use them. -***Note:*** _Kotlin's rather complex [documentation][ref-string-functions] pages hide extension functions in the default view. -Be sure to click `Members and Extensions` to expand this section._ +~~~~exercism/note +Kotlin's rather complex [documentation][ref-string-functions] pages hide extension functions in the default view. +Be sure to click `Members and Extensions` to expand this section. + +[ref-string-functions]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/ +~~~~ The following example shows just a small selection of what is available: From ef51a231db2664af339071c629db800b0841c279 Mon Sep 17 00:00:00 2001 From: Colin Leach Date: Mon, 1 Sep 2025 20:09:59 -0700 Subject: [PATCH 4/4] Update concepts/strings/about.md Co-authored-by: Derk-Jan Karrenbeld --- concepts/strings/about.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/concepts/strings/about.md b/concepts/strings/about.md index 72806268..734cf5d9 100644 --- a/concepts/strings/about.md +++ b/concepts/strings/about.md @@ -70,7 +70,8 @@ Mostly, these are [`extensions functions`][ref-extensions] rather than members o ~~~~exercism/note Kotlin's rather complex [documentation][ref-string-functions] pages hide extension functions in the default view. -Be sure to click `Members and Extensions` to expand this section. +At moment of writing this, the most valuable content is hidden in a tab named `Members and Extensions`. +Click it to expand this section and see all the members and extensions available on the `String` class. [ref-string-functions]: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/ ~~~~