Character

@frozen
struct Character
  • SwifterSwift: Check if character is emoji.

       Character("😀").isEmoji -> true
    

    Declaration

    Swift

    var isEmoji: Bool { get }
  • int

    SwifterSwift: Integer from character (if applicable).

       Character("1").int -> 1
       Character("A").int -> nil
    

    Declaration

    Swift

    var int: Int? { get }
  • SwifterSwift: String from character.

       Character("a").string -> "a"
    

    Declaration

    Swift

    var string: String { get }
  • SwifterSwift: Return the character lowercased.

       Character("A").lowercased -> Character("a")
    

    Declaration

    Swift

    var lowercased: Character { get }
  • SwifterSwift: Return the character uppercased.

       Character("a").uppercased -> Character("A")
    

    Declaration

    Swift

    var uppercased: Character { get }
  • SwifterSwift: Random character.

    Character.random() -> k

    Declaration

    Swift

    static func randomAlphanumeric() -> Character

    Return Value

    A random character.

  • SwifterSwift: Repeat character multiple times.

       Character("-") * 10 -> "----------"
    

    Declaration

    Swift

    static func * (lhs: Character, rhs: Int) -> String

    Parameters

    lhs

    character to repeat.

    rhs

    number of times to repeat character.

    Return Value

    string with character repeated n times.

  • SwifterSwift: Repeat character multiple times.

       10 * Character("-") -> "----------"
    

    Declaration

    Swift

    static func * (lhs: Int, rhs: Character) -> String

    Parameters

    lhs

    number of times to repeat character.

    rhs

    character to repeat.

    Return Value

    string with character repeated n times.