diff --git a/Source/IGListSwiftKit/ListIdentifiable.swift b/Source/IGListSwiftKit/ListIdentifiable.swift index 3a5d0489..8ec4f3d8 100644 --- a/Source/IGListSwiftKit/ListIdentifiable.swift +++ b/Source/IGListSwiftKit/ListIdentifiable.swift @@ -33,11 +33,10 @@ public extension ListIdentifiable { // TODO(natesm): Should this be a public API? It is for now. init?(diffable: Any) { - if let value = (diffable as? ListDiffableValueBox)?.value { - self = value - } else { + guard let value = (diffable as? ListDiffableValueBox)?.value else { return nil } + self = value } } @@ -63,10 +62,9 @@ private final class ListDiffableValueBox: NSObject, Lis } func isEqual(toDiffableObject object: ListDiffable?) -> Bool { - if let other = object as? ListDiffableValueBox { - return value == other.value - } else { + guard let other = object as? ListDiffableValueBox else { return false } + return value == other.value } } diff --git a/Source/IGListSwiftKit/ListValueSectionController.swift b/Source/IGListSwiftKit/ListValueSectionController.swift index e018c540..4b2b5d7a 100644 --- a/Source/IGListSwiftKit/ListValueSectionController.swift +++ b/Source/IGListSwiftKit/ListValueSectionController.swift @@ -23,12 +23,11 @@ open class ListValueSectionController: ListSectionContr /// Subclasses of `ListValueSectionController` may not override `didUpdate(to:)` for objects. /// Instead, they must use the overload for generic values. public final override func didUpdate(to object: Any) { - if let value = Value(diffable: object) { - self.value = value - didUpdate(to: value) - } else { + guard let value = Value(diffable: object) else { fatalError("Expected object for value section controller to be a boxed \(Value.self), but it was \(object)") } + self.value = value + didUpdate(to: value) } /// Updates the section controller to a new value.