To be answered
String can be created by enclosing a sequence of characters within double quotation marks.
let str = "Hello, World!" let substring = str.prefix(5) print(substring)
let str = #"This is a "quoted" string."# print(str)
let str = "Hello, World!" let count = str.components(separatedBy: "o").count - 1 print(count)
var str = "Hello, World!" str.remove(at: str.index(str.startIndex, offsetBy: 7)) print(str)
let str = "Hello, World!" let range = str.index(str.startIndex, offsetBy: 7)..<str.endIndex let substring = str[range] print(substring)
let str = "Hello, World!" let index = str.firstIndex(of: ",") ?? str.endIndex let substring = str[..<index] print(substring)
let str = "Apple, Banana, Cherry" let components = str.split(separator: ",") let count = components.count print(count)
let str = " Hello, World! "
let number = 42 let str = String(number) let result = str.count print(result)
var str1 = "" var str2 = String() if (str1 == str2) { print("Equal") } else { print("Not Equal") }
Subscribe to our newsletter