Functions

The following functions are available globally.

  • Returns true if right pattern is match with left string, the pattern string would converts to a NSRegularExpression automaticlly in method.

    Declaration

    Swift

    public func =~(str: String, pattern: RegexConvertible) -> Bool

    Parameters

    str

    A string waiting to match

    pattern

    A pattern used to match the string

    Return Value

    A bool value indicates whether the str is matched with the pattern

  • Returns true if right pattern is match with left character, the pattern string would converts to a NSRegularExpression automaticlly in method. This method use =~(str:pattern) internal to match char with pattern.

    Declaration

    Swift

    public func =~(left: Character, right: RegexConvertible) -> Bool

    Parameters

    left

    A Character waiting to match

    right

    A pattern used to match the string

    Return Value

    A bool value indicates whether the char is matched with the pattern

  • Returns a new String containing integer copies of the receiver. integer must be greater than or equal to 0. If integer is less than of equal to 0, this methods will return an empty string.

    let string = "String"
    string * 3              #=> "StringStringString"
    

    Declaration

    Swift

    public func *(left: String, right: Int) -> String

    Parameters

    left

    A string

    right

    A integer indicates how many times the string will duplicate

    Return Value

    A new String containing integer copies of the receiver

  • Returns a new String containing integer copies of the receiver. integer must be greater than or equal to 0. If integer is less than of equal to 0, this methods will return an empty string.

    let string = "String"
    3 * string              #=> "StringStringString"
    

    Declaration

    Swift

    public func *(left: Int, right: String) -> String

    Parameters

    left

    A integer indicates how many times the string will duplicate

    right

    A string

    Return Value

    A new String containing integer copies of the receiver

  • Returns a new String containing the two strings passed into this operator.

    "Hello" << " World"     #=> "Hello World"
    

    Declaration

    Swift

    public func <<(left: String, right: String) -> String

    Parameters

    left

    A string

    right

    Anther string

    Return Value

    A new string containing the two strings passed into this operator

  • Returns a new hash containing the contents of otherHash and the contents of hsh. the value for entries with duplicate keys will be that of rhs

    let h1 = ["a": 100, "b": 200]
    let h2 = ["b": 254, "c": 300]
    h1 + h2     #=> ["a": 100, "b": 254, "c": 300]
    
    See more

    Declaration

    Swift

    public func +<K, V>(lhs: Hash<K, V>, rhs: Hash<K, V>) -> Hash<K, V>

    Parameters

    left

    A hash.

    right

    Another hash.

    Return Value

    Returns a new hash containing the contents of otherHash and the contents of hsh.

  • Raises integer to the power of numeric, which may be negative or fractional. The result may be overflow.

    1 ** 2      #=> 1
    2 ** 2      #=> 4
    -2 ** 2     #=> 4
    -(2 ** 2)   #=> -4
    -2 ** 0     #=> 1
    

    Declaration

    Swift

    public func **(integer: Int, numeric: Int) -> Int

    Parameters

    integer

    An integer indicates the numeric

    numeric

    An integer indicates the power

    Return Value

    An integer which is the power of numeric

  • Raises integer to the power of numeric, which may be negative or fractional.

    1 ** 2      #=> 1
    2 ** 2      #=> 4
    -2 ** 2     #=> 4
    -(2 ** 2)   #=> -4
    -2 ** 0     #=> 1
    

    Declaration

    Swift

    public func **(double: Double, numeric: Double) -> Double

    Parameters

    double

    An double indicates the numeric

    numeric

    An double indicates the power

    Return Value

    An integer which is the power of numeric