Swift Characters

In this tutorial you will learn about the Swift Characters and its application with practical example.

Swift Characters

A character is used to represents a single literal, it could an alphabet, number or any special symbol.In Swift, character data type is used to hold a character value. Character can also be a languages character other than English using escape sequence \u{n} (unicode code point ,where n is in hexadecimal)

Declaring character

In Swift, character is declared same as string using double quotes.

Syntax:-

Example:-

Loop through characters from string

In Swift, string is a collection of characters thus it is possible to loop through characters from given string using for-in loop as following –

Example:-

Output:-

loop-through-characters-in-string

In this tutorial we have learn about the Swift Characters and its application with practical example. I hope you will like this tutorial.