Skip to content

Commit 03410c6

Browse files
authored
typo identity and remove final val
1 parent 7bf53e3 commit 03410c6

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

docs/docs/reference/metaprogramming/inline.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ type `1`.
216216
```scala
217217
inline def zero() <: Int = 0
218218

219-
final val one: 1 = zero() + 1
219+
val one: 1 = zero() + 1
220220
```
221221

222222
## Inline Conditionals
@@ -285,7 +285,7 @@ inline def toInt(n: Nat) <: Int = inline n match {
285285
case Succ(n1) => toInt(n1) + 1
286286
}
287287

288-
final val natTwo = toInt(Succ(Succ(Zero)))
288+
val natTwo = toInt(Succ(Succ(Zero)))
289289
val intTwo: 2 = natTwo
290290
```
291291

@@ -309,7 +309,7 @@ inline def toIntC[N] <: Int =
309309
case _: S[n1] => 1 + toIntC[n1]
310310
}
311311

312-
final val ctwo = toIntC[2]
312+
val ctwo = toIntC[2]
313313
```
314314

315315
`constValueOpt` is the same as `constValue`, however returning an `Option[T]`
@@ -338,6 +338,8 @@ called. But the function can in fact never be called, since it is declared
338338
Using `erasedValue`, we can then define `defaultValue` as follows:
339339

340340
```scala
341+
import scala.compiletime.erasedValue
342+
341343
inline def defaultValue[T] = inline erasedValue[T] match {
342344
case _: Byte => Some(0: Byte)
343345
case _: Char => Some(0: Char)
@@ -372,7 +374,7 @@ inline def toIntT[N <: Nat] <: Int = inline scala.compiletime.erasedValue[N] mat
372374
case _: Succ[n] => toIntT[n] + 1
373375
}
374376

375-
final val two = toIntT[Succ[Succ[Zero.type]]]
377+
val two = toIntT[Succ[Succ[Zero.type]]]
376378
```
377379

378380
`erasedValue` is an `erased` method so it cannot be used and has no runtime
@@ -392,6 +394,8 @@ If an inline expansion results in a call `error(msgStr)` the compiler
392394
produces an error message containing the given `msgStr`.
393395

394396
```scala
397+
import scala.compiletime.error
398+
395399
inline def fail() = {
396400
error("failed for a reason")
397401
}
@@ -404,7 +408,7 @@ or
404408
inline def fail(p1: => Any) = {
405409
error(code"failed on: $p1")
406410
}
407-
fail(indentity("foo")) // error: failed on: indentity("foo")
411+
fail(identity("foo")) // error: failed on: identity("foo")
408412
```
409413

410414
## Summoning Implicits Selectively

0 commit comments

Comments
 (0)