val someIterator
= Seq
(T
("a"), T
("b"), T
("b"), T
("a"), T
("b"), T
("a")).
toIterator
val xs
= someIterator.
map(_.
property).
collect(unlift
{ case "a" => foo +
= 1; None
case "b" => Some
("current foo" + foo
) })
println(xs.toList)
}
aW1wb3J0IEZ1bmN0aW9uLnVubGlmdAoKY2FzZSBjbGFzcyBUKHByb3BlcnR5OiBTdHJpbmcpCgpvYmplY3QgTWFpbiBleHRlbmRzIEFwcCB7Cgl2YWwgc29tZUl0ZXJhdG9yID0gU2VxKFQoImEiKSwgVCgiYiIpLCBUKCJiIiksIFQoImEiKSwgVCgiYiIpLCBUKCJhIikpLnRvSXRlcmF0b3IKCgl2YXIgZm9vID0gMAoJdmFsIHhzID0gc29tZUl0ZXJhdG9yLm1hcChfLnByb3BlcnR5KS5jb2xsZWN0KHVubGlmdCB7CgkgIGNhc2UgImEiID0+IGZvbyArPSAxOyBOb25lCgkgIGNhc2UgImIiID0+IFNvbWUoImN1cnJlbnQgZm9vIiArIGZvbykKCX0pCgoJcHJpbnRsbih4cy50b0xpc3QpCn0=