You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/welcome/welcome.md
+12-8Lines changed: 12 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -139,8 +139,9 @@ val newImprovedBjarne = originalBjarne.copy(favoriteLanguageId = scalaLanguage.i
139
139
140
140
<small>Try it in <ahref="https://scastie.scala-lang.org/CKL6DnTRQyuXbKNS3kwsjQ"><imgsrc="../img/media/welcome/scastie.png"alt="try it in scastie"width="10%"height="10%"style="vertical-align: middle;"></a></small>
141
141
142
-
> [!WARNING]
143
-
> `case class` doesn’t guarantee deep immutability. Its fields are `val` by default, but those fields can still refer to mutable objects.
142
+
@:warning
143
+
`case class` doesn’t guarantee deep immutability. Its fields are `val` by default, but those fields can still refer to mutable objects.
144
+
@:@
144
145
145
146
The important point is that operations on immutable values produce new values instead of changing existing ones. After calling `copy`, both `originalBjarne` and `newImprovedBjarne` remain available, and each retains its own value.
146
147
@@ -527,8 +528,9 @@ final case class NotYet(thunk: () => Unit) {
527
528
}
528
529
```
529
530
530
-
> [!NOTE]
531
-
> If you are familiar with void in other languages, Scala’s `Unit` serves a similar purpose: it indicates that a computation does not produce a meaningful result. Unlike `void`, `Unit` is a real type with exactly one value, `()`.
531
+
@:note
532
+
If you are familiar with void in other languages, Scala’s `Unit` serves a similar purpose: it indicates that a computation does not produce a meaningful result. Unlike `void`, `Unit` is a real type with exactly one value, `()`.
533
+
@:@
532
534
533
535
When you create it, nothing runs; you have contained the side effect.
534
536
@@ -947,8 +949,9 @@ object NotYet {
947
949
}
948
950
```
949
951
950
-
> [!NOTE]
951
-
> The `=>` marks value as a by-name parameter. It lets us give delay some code to run later without wrapping that code in `() =>`. The `delay` method takes care of wrapping it in a `thunk` for us.
952
+
@:note
953
+
The `=>` marks value as a by-name parameter. It lets us give delay some code to run later without wrapping that code in `() =>`. The `delay` method takes care of wrapping it in a `thunk` for us.
954
+
@:@
952
955
953
956
Now that we have some helpers with constructors, `flatMap`, `map`, and a `println`, we can simplify how we do everything. Here is `rollDice`
Cheers all around! We just loosely reinvented the basic shape of `IO`, a foundational type from Cats Effect. `IO` lets us build and combine work such as printing and generating random numbers without doing that work immediately. *We decide* when the complete program is finally run.
1168
1171
1169
-
> [!NOTE]
1170
-
> This `IO` is a teaching model. Cats Effect’s `IO` provides stack-safe composition, cancellation, concurrency, resource-safety tools, and many other capabilities. Our version is intended only to demonstrate how effectful programs can be represented as data and interpreted later.
1172
+
@:note
1173
+
This `IO` is a teaching model. Cats Effect’s `IO` provides stack-safe composition, cancellation, concurrency, resource-safety tools, and many other capabilities. Our version is intended only to demonstrate how effectful programs can be represented as data and interpreted later.
1174
+
@:@
1171
1175
1172
1176
You now know everything. Go forth, and program! But wait! A few more things.
0 commit comments