Open Xcode.Click on Get Started with Playground.Name the playground.Then Create.
Then type following codes or copy it.
import UIKit
//var stands variable and let stands constant
let check: Bool = false
var number:Int = 0
//Explicitly datatype is not required.
var withoutDataType = 7
//you can assign new value to variable
number = 1
//Can not assign new value to constant
//check = true
var name :String = "My name is Sabita"
var money :Float = 33.00
var weight : Double = 33.7987
//Value will naver change to other data type.We can explicitly convert
var moneyString = name + String(money)
var another = "\(name)\(money)"
var dict = [String :Int]()
dict = ["hello" :2,"i" :1,]//At last you can can add , .It is optional
dict["i"] //Access value by its key
let array = [1,2,3,4]
No comments:
Post a Comment