Associative array/Creation: Difference between revisions

→‎{{header|Julia}}: add julia example
No edit summary
(→‎{{header|Julia}}: add julia example)
Line 1,113:
 
=={{header|Julia}}==
We build dictionaries associating to some characters their code points, by listing the key/value pairs, through a dictionary comprehension, by creating an empty dictionary and filling it, finally by using the specific syntax associated to typed dictionaries and finally from two arrays using a constructor.
<lang julia>julia> hash = {'a' => 97, 'b' => 98} # list keys/values
{'a'=>97,'b'=>98}
Line 1,134:
julia> hash["a"] = 1 # type mismatch
ERROR: no method convert(Type{Char}, ASCIIString)
in setindex! at dict.jl:533</lang>
 
julia> hash = Dict(['a','b','c'], [97,98,99]) # constructor
['a'=>97,'c'=>99,'b'=>98]
 
julia> typeof(hash) # type is infered correctly
Dict{Char,Int64} (constructor with 3 methods</lang>
 
=={{header|K}}==