Character

struct Character
  • SwifterSwift: Check if character is emoji.

    Character("😀").isEmoji -> true
    

    Declaration

    Swift

    public var isEmoji: Bool
  • SwifterSwift: Check if character is number.

    Character("1").isNumber -> true
    Character("a").isNumber -> false
    

    Declaration

    Swift

    public var isNumber: Bool
  • SwifterSwift: Check if character is a letter.

    Character("4").isLetter -> false
    Character("a").isLetter -> true
    

    Declaration

    Swift

    public var isLetter: Bool
  • SwifterSwift: Check if character is lowercased.

       Character("a").isLowercased -> true
       Character("A").isLowercased -> false
    

    Declaration

    Swift

    public var isLowercased: Bool
  • SwifterSwift: Check if character is uppercased.

    Character("a").isUppercased -> false
    Character("A").isUppercased -> true
    

    Declaration

    Swift

    public var isUppercased: Bool
  • SwifterSwift: Check if character is white space.

    Character(" ").isWhiteSpace -> true
    Character("A").isWhiteSpace -> false
    

    Declaration

    Swift

    public var isWhiteSpace: Bool
  • int

    SwifterSwift: Integer from character (if applicable).

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

    Declaration

    Swift

    public var int: Int?
  • SwifterSwift: String from character.

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

    Declaration

    Swift

    public var string: String
  • SwifterSwift: Return the character lowercased.

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

    Declaration

    Swift

    public var lowercased: Character
  • SwifterSwift: Return the character uppercased.

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

    Declaration

    Swift

    public var uppercased: Character
  • SwifterSwift: Repeat character multiple times.

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

    Declaration

    Swift

    public 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

    public 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.