Groovy casting
examples/groovy/casting_string_to_integer.groovy
def x = "23" println(x + 4) // 234 def y = x as Integer println(y + 4) // 27 println((x as Integer) + 4) // 27
examples/groovy/casting_arraylist_to_string.groovy
def names = ['Foo', 'Bar'] z = names as String println(names) // [Foo, Bar] println(z) // [Foo, Bar] println(names.getClass()) // class java.util.ArrayList println(z.getClass()) // class java.lang.String

Published on 2019-04-21
If you have any comments or questions, feel free to post them on the source of this page in GitHub. Source on GitHub.
Comment on this post