Skip to content

Commit a305bb4

Browse files
committed
Add doctest environments to Val{T} documentation
1 parent 54a1bd0 commit a305bb4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

doc/manual/types.rst

+6-2
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,9 @@ If you apply :func:`super` to other type objects (or non-type objects), a
12491249
As one application of these ideas, Julia includes a parametric type,
12501250
``Val{T}``, designated for dispatching on bits-type *values*. For
12511251
example, if you pass a boolean to a function, you have to test the
1252-
value at run-time::
1252+
value at run-time:
1253+
1254+
.. doctest::
12531255

12541256
function firstlast(b::Bool)
12551257
return b ? "First" : "Last"
@@ -1258,7 +1260,9 @@ value at run-time::
12581260
println(firstlast(true))
12591261

12601262
You can instead cause the conditional to be evaluated during function
1261-
compilation by using the ``Val`` trick::
1263+
compilation by using the ``Val`` trick:
1264+
1265+
.. doctest::
12621266

12631267
firstlast(::Val{true}) = "First"
12641268
firstlast(::Val{false}) = "Last"

0 commit comments

Comments
 (0)