Swift Program to Demonstrate the Int() Function With Invalid Value

You are currently viewing Swift Program to Demonstrate the Int() Function With Invalid Value

Swift program to demonstrate the Int() function with Invalid value

// Swift program to demonstrate the
// Int() function with Invalid value

import Swift;

var strCode:String = "ABCDEF";
if let num = Int(strCode)
{
    print("Number is: ",num);
}
else
{
    print("String does not contain valid number.");
}

output

String does not contain valid number.

...Program finished with exit code 0
Press ENTER to exit console.

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply