Gamya ๐ธ Swift Strings โจ In Swift, text stored in a variable or constant is called a...
In Swift, text stored in a variable or constant is called a string.
Strings are written using double quotes.
let animeHero = "Hinata Hyuga"
let flower = "Cherry Blossom ๐ธ"
To include quotes inside a string, escape them with a backslash:
let quote = "She said, \"Every flower blooms in its own time.\""
Regular strings cannot span multiple lines.
For longer text, use triple quotes:
let poem = """
Petals fall softly,
Anime dreams rise high,
Spring never fades.
"""
Swift keeps line breaks exactly as written.
print(animeHero.count)
Swift correctly counts emoji and Unicode characters.
print(flower.uppercased())
print(poem.hasPrefix("Petals"))
print(flower.hasSuffix("๐ธ"))
โ ๏ธ String comparisons in Swift are case-sensitive.
Swift strings are safe, Unicode-aware, and powerful.
Whether itโs anime dialogue or flower names, Swift handles text beautifully ๐ธโจ