Enter your E-mail Address below for Free E-mail Alerts right Into your Inbox: -

Sunday

Swift Data Types


Swift Data Types

Commonly used data types by Swift are String,Int,Float,Double,Bool. Lets discuss each of this in detail. Here is an example how we declare a some data types in Swift.

Example:


let a:String  =  "hai i am here";
let b:Int  =  "10";
let c:Float = 7.36;
let d:Double = 1.2;
let e:Bool = true;



An wonderful feature of Swift was its Type Inference. The benefit of type inference is Swift variable identifies the type of variables assigned to it and make the variable as its type.

For example : To assign a Double value you can use like this.

var t = 1.5;

In the above code Swift compiler will take "t" as a Double Data Type.

No comments:

Post a Comment