[ https://issues.apache.org/jira/browse/GROOVY-9470?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17059774#comment-17059774 ]
Eric Milles commented on GROOVY-9470: ------------------------------------- Duplicate of GROOVY-8411 See also https://github.com/groovy/groovy-eclipse/issues/1056 > Automatic type casting with switch..case with instanceof > -------------------------------------------------------- > > Key: GROOVY-9470 > URL: https://issues.apache.org/jira/browse/GROOVY-9470 > Project: Groovy > Issue Type: Improvement > Components: Compiler > Affects Versions: 3.0.2 > Reporter: Marcin Zajaczkowski > Priority: Minor > > It could be useful to have automatic type casting (also with static > compilation) with switch..case with instanceof: > {code:java} > void sortItOut(Object o) { > switch(o) { > case String: > println "String: ${o.length()}" //currently only in dynamic Groovy > break > case Integer: > println "Integer: ${o.longValue()}" //currently only in dynamic > Groovy > break > default: > throw new IllegalArgumentException(o.toString()) > } > } > {code} > The same as currently for if with instanceof: > {code:java} > if (o instanceof String) { > useString(o) > } > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)