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

bookmark

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.