![]() |
VOOZH | about |
The Swift language supports different types of generic collections and a string is one of them. A string is a collection of alphabets. In the Swift string, we check if the specified string is present in a string or not. To do this task we use the contains() function. This function is used to check whether the specified string i.e. sequence of characters is present in the string or not. It will return true if the given string is present in the string otherwise it will return false.
Syntax:
string.contains(char: charSequence)
Here string is an object of the string class.
Parameters: This function accepts a parameter that is illustrated below:
Return Value: This function will return true if the given string is present in the string otherwise it will return false.
Example 1:
Output:
true false
Example 2:
Output:
Blank space is present in the string Computer Science is not present in the string