diff --git a/base/strings/lazy.jl b/base/strings/lazy.jl index a2f872c40660e..4d918807a3576 100644 --- a/base/strings/lazy.jl +++ b/base/strings/lazy.jl @@ -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. """ @@ -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. """