iOS HMSimilar

HMSimilar is a protocol for comparing, in a more "relaxed" form than Equatable, two objects of same type.

Table of Contents

Type Methods

Infix method for comparing 2 types for similarity.

Declaration

static func ~=(lhs: Self, rhs: Self) -> Bool

Parameters

lhs

(Self) One object to compare

rhs

(Self) Other object to compare

Returns

Bool

Discussion

Similarity indicates the two values are "similar enough" to be considered equal in most scenarios. However, it doesn't guarantee them to be "equal".

Example

import HMKit

let objectOne: ObjectConformingToHMSimilar!
let objectTwo: ObjectConformingToHMSimilar!
let areSimilar: Bool = objectOne ~= objectTwo