What is the lowercased() method of a string in Swift?

Overview

The lowercased() method of a string instance in Swift is used to return a lowercase copy of a string.

Syntax

string.lowercased()

Parameters

There are no parameters for this method.

Return value

The lowercase version of the string is returned.

Code example

// create some strings
let str1 = "Edpresso is the Best"
let str2 = "Best PLACE TO BE"
let str3 = "Learn all YOU need"
// get the lowwer case versions
print(str1.lowercased())
print(str2.lowercased())
print(str3.lowercased())

Explanation

  • Lines 2–4: We created some strings.
  • Lines 7–9: The lowercase versions of the strings were obtained using the lowercased() method. The results were printed to the console.