[ https://issues.apache.org/jira/browse/GROOVY-8006?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Guillaume Laforge updated GROOVY-8006: -------------------------------------- Description: With try with resources, it would be nice to be able the type or def, just like in the classical for loop: {code} import java.util.zip.GZIPOutputStream def input = new File('./NOTICE') def output = new File('/tmp/zipped.zip') try ( fin = new FileInputStream(input); out = new GZIPOutputStream(new FileOutputStream(output)) ) { byte[] buffer = new byte[4096] int nread = 0 while ((nread = fin.read(buffer)) != -1) { out.write(buffer, 0, nread) } } {code} was: With try with resources, it would be nice to be able the type or def, just like in the classical for loop: {code} import java.util.zip.GZIPOutputStream def input = new File('./NOTICE') def output = new File('/tmp/zipped.zip') try ( fin = new FileInputStream(input); out = new GZIPOutputStream(new FileOutputStream(output)) ) { byte[] buffer = new byte[4096] int nread = 0 while ((nread = fin.read(buffer)) != -1) { out.write(buffer, 0, nread) } } {code} > Allow dropping 'def' or type in try with resources > -------------------------------------------------- > > Key: GROOVY-8006 > URL: https://issues.apache.org/jira/browse/GROOVY-8006 > Project: Groovy > Issue Type: Improvement > Environment: Parrot parser > Reporter: Guillaume Laforge > > With try with resources, it would be nice to be able the type or def, just > like in the classical for loop: > {code} > import java.util.zip.GZIPOutputStream > def input = new File('./NOTICE') > def output = new File('/tmp/zipped.zip') > try ( > fin = new FileInputStream(input); > out = new GZIPOutputStream(new FileOutputStream(output)) > ) { > byte[] buffer = new byte[4096] > int nread = 0 > while ((nread = fin.read(buffer)) != -1) { > out.write(buffer, 0, nread) > } > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)