I have a seed value Triangle (Bool)
and an observable that emits values Circle (Int)
. My intention is to generate a new observable (Triangle, Circle)
each time a value is emitted from that observable, transforming the Triangle
value negating the current value. This is my marble diagram:
But I cannot achieve it, and I don't know if scan
is the correct operator. This is my code:
typealias Triangle = Bool
typealias Circle = Int
func scan() {
let triangle: Triangle = false
circleObservable
.scan(triangle, accumulator: ({ (triangle, circle) -> (Triangle, Circle) in
return (!triangle, circle)
}))
}
This generates a compiler error:
Cannot convert value of type '(Triangle, Circle) -> (Triangle, Circle)' (aka '(Bool, Int) -> (Bool, Int)') to expected argument type '(_, _) -> _'
Thanks!