Swift Tutorial - Tutorialspoint

(backadmin) #1
return nil
}

}

}

let circname = rectangle()
circname.print?[ 0 ] = radius(radiusname: "Diameter")

let printing = circle()
printing.area.append(radius(radiusname: "Units"))
printing.area.append(radius(radiusname: "Meter"))
circname.print = printing

var area = ["Radius": [ 35 , 45 , 78 , 101 ], "Circle": [ 90 , 45 , 56 ]]
area["Radius"]?[ 1 ] = 78
area["Circle"]?[ 1 ]--

println(area["Radius"]?[ 0 ])
println(area["Radius"]?[ 1 ])
println(area["Radius"]?[ 2 ])
println(area["Radius"]?[ 3 ])

println(area["Circle"]?[ 0 ])
println(area["Circle"]?[ 1 ])
println(area["Circle"]?[ 2 ])

When we run the above program using playground, we get the following result:


Optional(35)
Optional(78)
Optional(78)
Optional(101)
Optional(90)
Optional(44)
Optional(56)
Free download pdf