Groovy web console

subscribe to the feed Subscribe
to this
site

TypeChecked-fail-int-x.groovy

Published 4 months ago by Anonymous
Actions Execute script  ▶ Edit in console Back to console Show/hide line numbers View recent scripts
// TypeChecked-fail-int-x.groovy
// https://stackoverflow.com/questions/74573276/why-does-the-groovy-typechecked-annotation-catch-me-putting-a-string-into-an-in
@groovy.transform.TypeChecked
void m(){
    int x

    x = 123
    println(x)
    println(x.getClass())

    println()

    x = "abc"
    println(x)
    println(x.getClass())
}

m()