Character

struct Character
  • SwifterSwift: Check if character is emoji.

    Character("😀").isEmoji -> true
    

    Declaration

    Swift

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

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

    Declaration

    Swift

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

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

    Declaration

    Swift

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

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

    Declaration

    Swift

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

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

    Declaration

    Swift

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

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

    Declaration

    Swift

    public var isWhiteSpace: Bool { get }
  • int

    SwifterSwift: Integer from character (if applicable).

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

    Declaration

    Swift

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

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

    Declaration

    Swift

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

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

    Declaration

    Swift

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

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

    Declaration

    Swift

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

    Character.random() -> k

    Declaration

    Swift

    public static func randomAlphanumeric() -> Character

    Return Value

    A random 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.