Skip to content

Commit

Permalink
Update task.md
Browse files Browse the repository at this point in the history
language in hints checked
  • Loading branch information
stephen-hero authored Dec 23, 2023
1 parent 7406183 commit 465cebd
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions memoryTrainerServer/memoryTrainerServerCardService/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ If you have any difficulties, **hints will help you solve this task**.

### Hints

<div class="hint" title="Click me to learn about function definition of the SAM interfaces">
<div class="hint" title="Click me to learn about defining a function for SAM interfaces">

It is better to use a function definition for SAM interfaces:
```kotlin
Expand All @@ -40,9 +40,9 @@ val randomCardGenerator = CardSequenceGenerator {
```
</div>

<div class="hint" title="Click me to learn about the `map`built-in function">
<div class="hint" title="Click me to learn about the `map` built-in function">

You can use the built-in [`map`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/map.html) function to change each pair inside a map collection:
You can use the built-in [`map`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/map.html) function to modify each pair in a map collection:

```kotlin
val numbers = mapOf("one" to 1,"two" to 2, "three" to 3)
Expand All @@ -65,12 +65,12 @@ or use the built-in function [`shuffled`](https://kotlinlang.org/api/latest/jvm/
```
</div>

<div class="hint" title="Click me to learn about the main difference between mutable and readonly lists">
<div class="hint" title="Click me to learn about the main difference between mutable and read-only lists">

We'll go into the details of collections in the next module; for now, it is enough to know some basics facts:
1) We can create read-only and mutable lists.
1) We can create both read-only and mutable lists.
If you initialize a read-only list, you can only read its elements.
If you create a mutable list, you can change the elements after list initialization:
If you create a mutable list, you can modify its elements after list initialization:

```kotlin
val readOnlyNumbers = listOf(1, 2, 3, 4, 5, 6)
Expand All @@ -93,7 +93,7 @@ println(readOnlyNumbers[2]) // OK

<div class="hint" title="Click me to learn about the `isNotEmpty` built-in function">

In case you need to check that a list is not empty, you can check its size or use the built-in [isNotEmpty](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/is-not-empty.html) function:
In case you need to check that a list is not empty, you can either check its size or use the built-in [isNotEmpty](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/is-not-empty.html) function:

```kotlin
val numbers = listOf(1, 2, 3)
Expand All @@ -113,7 +113,7 @@ It is the **same** as

<div class="hint" title="Click me to learn about the `require` built-in function">

To check some condition and throw an `IllegalArgumentException` error, you can use the built-in [`require`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/require.html) function:
To check a certain condition and throw an `IllegalArgumentException` error if necessary, you can use the built-in [`require`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/require.html) function:

```kotlin
fun foo(a: int) {
Expand All @@ -130,12 +130,12 @@ fun foo(a: int) {
require (a >= 5) { "Some error message" }
}
```
Note, you need to use an _opposite_ condition!
Note that you need to use an _opposite_ condition!
</div>

<div class="hint" title="Click me to learn about the `removeFirst` built-in function">

If you need to get the first element from a mutable list and next remove it, you can use the built-in [`removeFirst`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/remove-first.html) function:
If you need to get the first element from a mutable list and then remove it, you can use the built-in [`removeFirst`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/remove-first.html) function:

```kotlin
fun main() {
Expand Down

0 comments on commit 465cebd

Please sign in to comment.