[ https://issues.apache.org/jira/browse/GROOVY-11654?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King resolved GROOVY-11654. -------------------------------- Fix Version/s: 5.0.0-alpha-13 Resolution: Fixed Proposed PR merged. > Create AGM#putAt variants > ------------------------- > > Key: GROOVY-11654 > URL: https://issues.apache.org/jira/browse/GROOVY-11654 > Project: Groovy > Issue Type: New Feature > Reporter: Paul King > Assignee: Paul King > Priority: Major > Fix For: 5.0.0-alpha-13 > > > When creating potential examples for the Groovy 5 release notes, I created > this example: > {code:groovy} > // keep top 5 scores in top array > int[] scores = [56, 82, 70, 74, 63, 92, 49, 69, 85, 79, 80, 82, 99, 95] > int[] top = scores[0..4].sort() > scores[5..-1].each { next -> > def ins = top.partitionPoint{ it < next } - 1 > if (ins > 0) { > System.arraycopy(top, 1, top, 0, ins) > // top[0..<ins] = top[1..ins] > } > if (ins >= 0) { > top[ins] = next > } > } > assert top == [82, 85, 92, 95, 99] > {code} > The {{System.arraycopy()}} line would be {{top[0..<ins] = top[1..ins]}} if > using lists. It would be nice if arrays supported putAt and that line didn't > need to change. -- This message was sent by Atlassian Jira (v8.20.10#820010)