Created
December 25, 2016 18:47
-
-
Save HIPERCUBE/53d0074f8bc1614574befa31511730d4 to your computer and use it in GitHub Desktop.
Groovy Range Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Number rangle | |
def range = 1..10 | |
assert range == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | |
// Character range | |
range = 'a'..'c' | |
assert range == ['a', 'b', 'c'] | |
range = 1..<8 | |
assert range == [1, 2, 3, 4, 5, 6, 7] | |
(1..5).each { println it } | |
assert[*1..4] == [1, 2, 3, 4] | |
assert[1, *2..4] == [1, 2, 3, 4] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment