-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Open
Labels
display and printingAesthetics and correctness of printed representations of objects.Aesthetics and correctness of printed representations of objects.
Description
From the documentation of the repr
it is not entirely clear if the context
keyword argument accepts multiple attributes. E.g. it says:
The optional keyword argument context can be set to :key=>value pair or an IO or IOContext object whose
attributes are used for the I/O stream passed to show.
What if I want to set multiple :key=>value pairs? This apparently works:
julia> repr(1; context=(:a => 1, :b => 2))
"1"
But is it the official way or it works by accident? For example this doesn't work
julia> repr(MIME"text/plain"(), 1; context=(:a => 1, :b => 2))
ERROR: MethodError: no method matching IOContext(::IOBuffer, ::Tuple{Pair{Symbol, Int64}, Pair{Symbol, Int64}})
The type `IOContext` exists, but no method is defined for this combination of argument types when trying to construct it.
Closest candidates are:
IOContext(::IO, ::Pair)
@ Base show.jl:333
IOContext(::IO, ::Pair, Pair...)
@ Base show.jl:413
IOContext(::IO, ::Base.ImmutableDict{Symbol, Any})
@ Base show.jl:316
...
Stacktrace:
Would be nice to clarify the usage of multiple attributes in the documentation.
Metadata
Metadata
Assignees
Labels
display and printingAesthetics and correctness of printed representations of objects.Aesthetics and correctness of printed representations of objects.