Standard Array,Set,Dictionary variable creation ways Swift programming language -
i'm beginner in swift language. there many ways declare/create variables in it. please fill code below. want know ways can declare arrays, sets , dictionaries.
var arr1 : [int] var arr2 = [int]() var arr3 : array<int> var arr4 = [1,2,3,4] var arr5 : array = [1,2,3,4] var arr6 : [array<int>] var dict1 : [int:int] var dict2 = [int:int]() var dict3 : dictionary<int,int> var dict4 = [1 : 2,3 : 4] var dict5 : dictionary = [1 : 2,3 : 4] var dict6 : [dictionary<string, int>] var dict7 = [dictionary<string, int>]() var dict8 = dictionary<int,int>() var set1 : set<int> var set2 = set<int>() var set3 : set = [1,2,3] var set4 : [set<int>] var set5 = [set<int>]()
your listing contains forms declare declare , initialize variable
two alternative forms of latter array , dictionary
var arr7 : [int] = [] // same arr2 var dict9 : [int:int] = [:] // same dict2, dict8
Comments
Post a Comment