summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorEdmilson Lima <filhoer@uol.com.br>2016-07-02 11:02:38 -0300
committerven <vendethiel@hotmail.fr>2016-07-02 16:02:38 +0200
commit5dee671bfef8c4ab253a1992f03176b72948f226 (patch)
tree0ebd8898d563858a9f17dc5d1470929c024a2a58
parenta7eed36c1da2a16c7ced96e4d5fb0fb03bd94716 (diff)
Update Dict and Set Syntax (#2296)
-rw-r--r--julia.html.markdown10
1 files changed, 5 insertions, 5 deletions
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]