Skip to content

Commit

Permalink
Merge pull request #25446 from JuliaLang/kc/iocontext_examples
Browse files Browse the repository at this point in the history
add more examples to iocontext
  • Loading branch information
Sacha0 authored Jan 8, 2018
2 parents 69eb29e + aafb37d commit 16707ba
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,28 @@ The following properties are in common use:
`--color` command-line flag when `julia` was launched.
# Examples
```jldoctest
julia> io = IOBuffer();
julia> print_with_color(:red, IOContext(io, :color => true), "string")
julia> String(take!(io))
"\e[31mstring\e[39m"
julia> print_with_color(:red, io, "string")
julia> String(take!(io))
"string"
```
```jldoctest
julia> print(IOContext(STDOUT, :compact => false), 1.12341234)
1.12341234
julia> print(IOContext(STDOUT, :compact => true), 1.12341234)
1.12341
```
```jldoctest
julia> function f(io::IO)
if get(io, :short, false)
Expand Down

0 comments on commit 16707ba

Please sign in to comment.