Skip to content

Commit 31f25cb

Browse files
committed
Add language syntax highlighting to code blocks
1 parent 40379ac commit 31f25cb

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

proposal.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ For persistent collection interfaces there shall be provided the following imple
4141
* Avoiding defensive copying of collection passed as a parameter
4242
when you need an unchangeable snapshot and you're unsure whether the collection could be changed later.
4343

44-
```
44+
```kotlin
4545
class Query(val parameters: ImmutableList<Parameter>)
4646

4747
// or
@@ -105,13 +105,13 @@ It can be done by the following means:
105105
106106
- chaining operations together
107107
108-
```
108+
```kotlin
109109
collection = collection.add(element).add(anotherElement)
110110
```
111111
112112
- applying operations one by one
113113
114-
```
114+
```kotlin
115115
collection += element
116116
collection += anotherElement
117117
```
@@ -125,7 +125,7 @@ For example, `PersistentSet.Builder<T>` extends `MutableSet<T>`.
125125
A builder can be obtained from a persistent collection with `builder()` method, and then that builder could be
126126
transformed back to a persistent collection with its `build()` method.
127127
128-
```
128+
```kotlin
129129
val builder = persistentList.builder()
130130
builder.removeAll { it.value > treshold }
131131
if (builder.isEmpty()) {
@@ -274,17 +274,21 @@ avoiding memory allocations in modification operations leads to significant perf
274274
Converts a read-only or mutable collection to immutable one.
275275
If the receiver is already immutable and has the required type, returns it as is.
276276
277-
fun Iterable<T>.toImmutableList(): ImmutableList<T>
278-
fun Iterable<T>.toImmutableSet(): ImmutableSet<T>
277+
```kotlin
278+
fun Iterable<T>.toImmutableList(): ImmutableList<T>
279+
fun Iterable<T>.toImmutableSet(): ImmutableSet<T>
280+
```
279281
280282
#### toPersistentList/Set/Map
281283
282284
Converts a read-only or mutable collection to persistent one.
283285
If the receiver is already persistent and has the required type, returns it as is.
284286
If the receiver is a builder of the required persistent collection type, calls `build` on it and returns the result.
285287
286-
fun Iterable<T>.toPersistentList(): PersistentList<T>
287-
fun Iterable<T>.toPersistentSet(): PersistentSet<T>
288+
```kotlin
289+
fun Iterable<T>.toPersistentList(): PersistentList<T>
290+
fun Iterable<T>.toPersistentSet(): PersistentSet<T>
291+
```
288292
289293
#### `+` and `-` operators
290294
@@ -295,11 +299,13 @@ If the receiver is a builder of the required persistent collection type, calls `
295299
A quite common pattern with builders arises: get a builder, apply some mutating operations on it,
296300
transform it back to an immutable collection:
297301
298-
collection.builder().apply { some_actions_on(this) }.build()
302+
```kotlin
303+
collection.builder().apply { some_actions_on(this) }.build()
304+
```
299305
300306
This pattern could be extracted to an extension function.
301307
302-
```
308+
```kotlin
303309
fun <T> PersitentList<T>.mutate(action: (MutableList<T>) -> Unit): PersitentList<T> =
304310
builder().apply { action(this) }.build()
305311
```

0 commit comments

Comments
 (0)