Check if string has prefix

 Problem

I have a string and want to check if there is a specific prefix.



 Recipe


// String literal
var a = "Hello World!"

// Check if there is a specific Prefix

if a.hasPrefix("Hell") {
    print("Yes, there is")
}
else {
    print("Error!")
}

				


 Playground