Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Consider the following code:

let op1: Int = 1

let op2: UInt = 2

let op3: Double = 3.34

var result = op1 + op2 + op3

Where is the error and why? How can it be fixed?



Consider the following code: let op1: Int = 1 let op2: UInt = 2 let op3: Double = 3.34 v..

Answer / iosraj

Swift doesn’t define any implicit cast between data types, even if they are conceptually almost identical (like UInt and Int).

To fix the error, rather than casting, an explicit conversion is required. In the sample code, all expression operands must be converted to a common same type, which in this case is Double:

var result = Double(op1) + Double(op2) + op3

Is This Answer Correct ?    4 Yes 0 No

Post New Answer

More Apple iOS Swift Interview Questions

What are ui elements?

0 Answers  


Explain the common execution states for a swift ios app (ios application lifecycle).

0 Answers  


Can you explain completion handler?

0 Answers  


Mention what are the features of Swift Programming?

1 Answers  


What is the use of continue statement in swift loop?

0 Answers  


Do swift classes inherit from nsobject?

0 Answers  


What is clean swift?

0 Answers  


What language is similar to swift?

0 Answers  


What language is swift most similar to?

0 Answers  


What is a swift protocol?

0 Answers  


Explain completion handler?

0 Answers  


What is a delegate in swift?

0 Answers  


Categories