Skip to content

Commit

Permalink
Add examples to LazyString docstrings (#44514)
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy authored Mar 17, 2022
1 parent 1e64682 commit 7ce6a5e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions base/strings/lazy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ of functions).
This type is designed to be cheap to construct at runtime, trying to offload
as much work as possible to either the macro or later printing operations.
# Examples
```jldoctest
julia> n = 5; str = LazyString("n is ", n)
"n is 5"
```
See also [`lazy"str"`](@ref).
!!! compat "Julia 1.8"
`LazyString` requires Julia 1.8 or later.
"""
Expand All @@ -26,6 +35,16 @@ Create a [`LazyString`](@ref) using regular string interpolation syntax.
Note that interpolations are *evaluated* at LazyString construction time,
but *printing* is delayed until the first access to the string.
# Examples
```
julia> n = 5; str = lazy"n is \$n"
"n is 5"
julia> typeof(str)
LazyString
```
!!! compat "Julia 1.8"
`lazy"str"` requires Julia 1.8 or later.
"""
Expand Down

0 comments on commit 7ce6a5e

Please sign in to comment.