var s1 = "One";
var s2 = "Two";
var s3 = "Three";
var emp = "";
// normal String print
print(s1);
// check string is empty
//1.
if emp.isEmpty{
print("This is empty string");
}else{
print(emp);
}
//2.
if s2.isEmpty{
print(" This is empty string");
}else{
print(s2);
}
// String constant
let b = String(" this is constant value");
//b = b+"var value"; // when uncomment - show error
print(b);
// String concatenation
print(s1+s2);
// count
print( s3.characters.count);
print(s3.utf16.count);
No comments:
Post a Comment