From 5dee671bfef8c4ab253a1992f03176b72948f226 Mon Sep 17 00:00:00 2001 From: Edmilson Lima Date: Sat, 2 Jul 2016 11:02:38 -0300 Subject: Update Dict and Set Syntax (#2296) --- julia.html.markdown | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'julia.html.markdown') diff --git a/julia.html.markdown b/julia.html.markdown index 23d834f4..5b3f6fd8 100644 --- a/julia.html.markdown +++ b/julia.html.markdown @@ -255,7 +255,7 @@ e, d = d, e # => (5,4) # d is now 5 and e is now 4 empty_dict = Dict() # => Dict{Any,Any}() # You can create a dictionary using a literal -filled_dict = ["one"=> 1, "two"=> 2, "three"=> 3] +filled_dict = Dict("one"=> 1, "two"=> 2, "three"=> 3) # => Dict{ASCIIString,Int64} # Look up values with [] @@ -305,7 +305,7 @@ in(10, filled_set) # => false other_set = Set([3, 4, 5, 6]) # => Set{Int64}(6,4,5,3) intersect(filled_set, other_set) # => Set{Int64}(3,4,5) union(filled_set, other_set) # => Set{Int64}(1,2,3,4,5,6) -setdiff(Set(1,2,3,4),Set(2,3,5)) # => Set{Int64}(1,4) +setdiff(Set([1,2,3,4]),Set([2,3,5])) # => Set{Int64}(1,4) #################################################### @@ -346,7 +346,7 @@ end # cat is a mammal # mouse is a mammal -for a in ["dog"=>"mammal","cat"=>"mammal","mouse"=>"mammal"] +for a in Dict("dog"=>"mammal","cat"=>"mammal","mouse"=>"mammal") println("$(a[1]) is a $(a[2])") end # prints: @@ -354,7 +354,7 @@ end # cat is a mammal # mouse is a mammal -for (k,v) in ["dog"=>"mammal","cat"=>"mammal","mouse"=>"mammal"] +for (k,v) in Dict("dog"=>"mammal","cat"=>"mammal","mouse"=>"mammal") println("$k is a $v") end # prints: @@ -445,7 +445,7 @@ end # You can define functions that take keyword arguments function keyword_args(;k1=4,name2="hello") # note the ; - return ["k1"=>k1,"name2"=>name2] + return Dict("k1"=>k1,"name2"=>name2) end keyword_args(name2="ness") # => ["name2"=>"ness","k1"=>4] -- cgit v1.2.3