groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Ledbrook <>
Subject Re: Type safety on sum()/getAt()
Date Mon, 12 Oct 2015 05:44:51 GMT
> 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



Peter Ledbrook
t: @pledbrook

View raw message