Skip to content

Commit 1d7d425

Browse files
elmira-mazanjulienrf
authored andcommitted
Fix difficult to read value name in example.
In my font (default for Firefox I think) the old name `l2` (i.e. _<lowercase L>_2) looks a lot like `12` (i.e. twelve). This changes the name to `log2` since that's a lot easier to parse. I was very confused thinking I was reading ```scala val d: Double = 12 // ERROR: Found Logarithm required Double ``` and wondering "how did the compiler decide that twelve was a Logarithm". Great book overall, thanks for putting it together!
1 parent 59ddfd5 commit 1d7d425

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

_overviews/scala3-book/types-opaque-types.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ However, outside of the module the type `Logarithm` is completely encapsulated,
124124

125125
```scala
126126
import Logarithms.*
127-
val l2 = Logarithm(2.0)
128-
val l3 = Logarithm(3.0)
129-
println((l2 * l3).toDouble) // prints 6.0
130-
println((l2 + l3).toDouble) // prints 4.999...
127+
val log2 = Logarithm(2.0)
128+
val log3 = Logarithm(3.0)
129+
println((log2 * log3).toDouble) // prints 6.0
130+
println((log2 + log3).toDouble) // prints 4.999...
131131

132-
val d: Double = l2 // ERROR: Found Logarithm required Double
132+
val d: Double = log2 // ERROR: Found Logarithm required Double
133133
```
134134

135135
Even though we abstracted over `Logarithm`, the abstraction comes for free:

0 commit comments

Comments
 (0)