> > I don't think it is possible without a breaking change. Today `sum` and > `getAt` can return anything. There's no requirement that the sum of A+A is > an A, nor that A+B return type is the same as B+A, or any kind of > constraint like that. Adding this at the source level would enforce type > safety, but it would also break existing code. >
That's a shame, but understandable. Would it be something to consider for Groovy 3 though? It seems strange that inject() does have the requisite type information but sum() does not. The fewer the inconsistencies the better. Cheers, Peter -- Peter Ledbrook t: @pledbrook w: http://www.cacoethes.co.uk/
