Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -0,0 +1,27 @@
|
|||
julia> hash = {'a' => 97, 'b' => 98} # list keys/values
|
||||
{'a'=>97,'b'=>98}
|
||||
|
||||
julia> hash = {c => int(c) for c = 'a':'d'} # dict comprehension
|
||||
{'a'=>97,'c'=>99,'b'=>98,'d'=>100}
|
||||
|
||||
julia> hash['é'] = 233 ; hash # add an element
|
||||
{'a'=>97,'c'=>99,'b'=>98,'é'=>233,'d'=>100}
|
||||
|
||||
julia> hash = Dict() # create an empty dict
|
||||
Dict{Any,Any}()
|
||||
|
||||
julia> for c = 'a':'d' hash[c] = int(c) end ; hash # fill it
|
||||
{'a'=>97,'c'=>99,'b'=>98,'d'=>100}
|
||||
|
||||
julia> hash = (Char=>Int64)['a' => 97, 'b' => 98] # create a typed dict
|
||||
['a'=>97,'b'=>98]
|
||||
|
||||
julia> hash["a"] = 1 # type mismatch
|
||||
ERROR: no method convert(Type{Char}, ASCIIString)
|
||||
in setindex! at dict.jl:533
|
||||
|
||||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue