You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I thought it was documented that setindex! calls convert on the value, and in some cases the "key".
e.g. convert both key and value:
julia> d =Dict{Int, Complex{Float64}}()
Dict{Int64, ComplexF64}()
julia> d[1.0] =truetrue
julia> d
Dict{Int64, ComplexF64} with 1 entry:1=>1.0+0.0im
convert just value, not key:
julia>push!(Vector{ComplexF64}(), true)
1-element Vector{ComplexF64}:1.0+0.0im
julia> [1][1.0] =3
ERROR: ArgumentError: invalid index:1.0 of type Float64
Is it correct to document that setindex! and push! does conversion of the value? I wondered this here.
help?> setindex!
search: setindex!
setindex!(collection, value, key...)
Store the given value at the given key or index within a collection. The syntax a[i,j,...] = x is converted by the compiler to
(setindex!(a, x, i, j, ...); x).
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
setindex!(A, X, inds...)
A[inds...] = X
Store values from array X within some subset of A as specified by inds. The syntax A[inds...] = X is equivalent to (setindex!(A, X,
inds...); X).
The text was updated successfully, but these errors were encountered:
One could argue it belongs in the docstrings, but I think in this case, it's more of a generic Julia behaviour thing, and less of a specific push! thing.
I thought it was documented that
setindex!
callsconvert
on the value, and in some cases the "key".e.g. convert both key and value:
convert just value, not key:
Is it correct to document that
setindex!
andpush!
does conversion of the value? I wondered this here.The text was updated successfully, but these errors were encountered: