What I am trying to do is define a list which asks for a specific type (List<Integer>
). During the initialization of the class I put in a list of String
I expect it to throw some runtime casting error. But it doesn't - it runs fine.
This is probably grails 101 stuff im sure but could someone explain why this works and also how I would force some type to be used in a list?
class Test {
String name
List<Integer> numbers
}
def myList = ['a','b','c']
Test myTest = new Test(name:'test', numbers:myList)
myTest.numbers.each() { print " $it" }
Output:
a b c