diff --git a/RxSwift/DataStructures/Bag.swift b/RxSwift/DataStructures/Bag.swift index fe074dec..92605d4a 100644 --- a/RxSwift/DataStructures/Bag.swift +++ b/RxSwift/DataStructures/Bag.swift @@ -152,7 +152,11 @@ public struct Bag : CustomDebugStringConvertible { - returns: Number of elements in bag. */ public var count: Int { - return _pairs.count + (_value0 != nil ? 1 : 0) + (_value1 != nil ? 1 : 0) + (_dictionary?.count ?? 0) + var dictionaryCount = 0 + if let dc = _dictionary?.count { + dictionaryCount = dc + } + return _pairs.count + (_value0 != nil ? 1 : 0) + (_value1 != nil ? 1 : 0) + dictionaryCount } /**