502
502

Reputation: 83

how to do this in groovy, range from 1 and greater

I want numbers from 1 and greater I tried 1..n, but this doesn't work So I can't do this in Range?

thanks

Upvotes: 2

Views: 1588

Answers (2)

Andrew Eisenberg
Andrew Eisenberg

Reputation: 28757

This works for me:

def n = 3
def range = 1..n
range.each { println it }

Output:

$ groovy range.groovy 
1
2
3

Can you provide a script that isn't behaving as you would like?

Upvotes: 3

Nicholas
Nicholas

Reputation: 16056

1..Integer.MAX_VALUE
or 
1..Long.MAX_VALUE

What do you want n to signify ?

Upvotes: 3

Related Questions