Dónal
Dónal

Reputation: 187539

Groovy one-liner compilation failure

The following Groovy code:

1.upTo(5) {println it}

Produces this compilation error:

No signature of method: java.lang.Integer.upTo() is applicable for argument types: (java.lang.Integer, ConsoleScript4$_run_closure1) values: [5, ConsoleScript4$_run_closure1@e83c97]

It appears that the method call matches the signature of this method, so what's the problem?

Thanks, Don

Upvotes: 1

Views: 248

Answers (2)

Michael Easter
Michael Easter

Reputation: 24478

The problem is the case on the upto call:

groovy -e " 1.upto(5) { println it } "

Upvotes: 1

jsight
jsight

Reputation: 28419

1.upTo(5) {println it}

should be

1.upto(5) {println it}

(Its an error in case... the "t" should be lower-case in "upto")

Upvotes: 3

Related Questions