groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [2/2] groovy git commit: range clarification
Date Tue, 07 Nov 2017 02:10:16 GMT
range clarification


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/7c4b0b41
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/7c4b0b41
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/7c4b0b41

Branch: refs/heads/GROOVY_2_5_X
Commit: 7c4b0b41a8fdfcfbbf1c3cb019e6efdd3023db48
Parents: fc03b8d
Author: paulk <paulk@asert.com.au>
Authored: Tue Nov 7 12:08:01 2017 +1000
Committer: paulk <paulk@asert.com.au>
Committed: Tue Nov 7 12:09:56 2017 +1000

----------------------------------------------------------------------
 src/spec/doc/style-guide.adoc | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/7c4b0b41/src/spec/doc/style-guide.adoc
----------------------------------------------------------------------
diff --git a/src/spec/doc/style-guide.adoc b/src/spec/doc/style-guide.adoc
index ed56c21..2ee13cc 100644
--- a/src/spec/doc/style-guide.adoc
+++ b/src/spec/doc/style-guide.adoc
@@ -492,7 +492,12 @@ def list = [1, 4, 6, 9]
 // you can wrap keys with () like [(variableStateAcronym): stateName] to insert a variable
or object as a key.
 def map = [CA: 'California', MI: 'Michigan']
 
-def range = 10..20
+// ranges can be inclusive and exclusive
+def range = 10..20 // inclusive
+assert range.size() == 21
+// use brackets if you need to call a method on a range definition
+assert (10..<20).size() == 20 // exclusive
+
 def pattern = ~/fo*/
 
 // equivalent to add()


Mime
View raw message