😉 Never implement Equatable manually again.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
DeftEquatable
Sample
.gitignore
.swift-version
DeftEquatable.podspec
LICENSE
README.md

README.md


Version Author Build Passing Swift
Platforms MIT
Cocoapods Carthage SPM

Introduction

What's this?

With DeftEquatable, you NEVER implement Equatable manually again.

Installation

CocoaPods

pod 'DeftEquatable'

Contribution

You are welcome to fork and submit pull requests.

License

DeftEquatable is open-sourced software, licensed under the MIT license.

Usage

import DeftEquatable

class MyClass: DeftEquatable {
    let myString: String
    let myInt: Int

    init(myString: String, myInt: Int) {
        self.myString = myString
        self.myInt = myInt
    }
}

class MyClassWithAnotherClass: DeftEquatable {
    let myClass: MyClass

    init(myClass: MyClass) {
        self.myClass = myClass
    }
}

enum GenericEnum: DeftEquatableEnum {
    case one
    case two
}

class MyClassWithGenericEnum: DeftEquatable {
    let myEnum: GenericEnum

    init(myEnum: GenericEnum) {
        self.myEnum = myEnum
    }
}

class MyClassWithArray<T>: DeftEquatable {
    let myArray: [T]

    init(myArray: [T]) {
        self.myArray = myArray
    }
}
let one = MyClass.init(myString: "somethings", myInt: 1)
let two = MyClass.init(myString: "somethings", myInt: 2)

let three = MyClassWithAnotherClass.init(myClass: two)
let four = MyClassWithAnotherClass.init(myClass: two)

let five = MyClassWithGenericEnum.init(myEnum: .one)
let six = MyClassWithGenericEnum.init(myEnum: .two)

let seven = MyClassWithArray<Int>.init(myArray: [1,2,3])
let eight = MyClassWithArray<Int>.init(myArray: [1,2,3])

print(one == two) // false
print(three == four) // true
print(five == six) // false
print(seven == eight) // true