Associative array/Creation: Difference between revisions

added swift
m (MATLAB/Octave: fixed capitalization of language tags)
(added swift)
Line 2,269:
output = t<"green">
end</lang>
 
=={{header|Swift}}==
<lang swift>// make an empty map
var a = Dictionary<String, Int>()
// or
var b: Dictionary<String, Int> = [:]
 
// make an empty map with an initial capacity
var c = Dictionary<String, Int>(minimumCapacity: 42)
 
// set a value
c["foo"] = 3
 
// make a map with a literal
var d = ["foo": 2, "bar": 42, "baz": -1]</lang>
 
=={{header|Tcl}}==
Anonymous user