groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Winnebeck, Jason" <>
Subject RE: Problem using 'is' in a command chain
Date Wed, 28 Oct 2015 12:54:10 GMT
'is' is a method on every object in Groovy, it's used as identity operation. 

a == b, maps to a.equals(b) in Java, maps to a == b in Java.

Your code is translating into: check(cond).is(true). I'm not sure why Groovy doesn't find
the "is" closure on your map before it finds the built-in "is", though, unless Groovy treats
"is" as a special case. However, considering that "is" is a foundational concept of Groovy,
you might not want to overload it anyway, unless you are trying not to expose "Groovy" to
your DSL.


-----Original Message-----
From: Marc Paquette [] 
Sent: Tuesday, October 27, 2015 11:17 PM
Subject: Problem using 'is' in a command chain

Playing with DSL here (going through chapter 19 of « Groovy In Action, second edition »,
well worth the read).  It seems that one cannot use the word ‘is’ to build a command chain
dsl, but ‘IS’ or ‘Is’ or ‘iS’ are ok… Or is it something I’m doing wrong ?

[marcpa@MarcPaquette dsl]$ groovy --version Groovy Version: 2.4.3 JVM: 1.8.0_60 Vendor: Oracle
Corporation OS: Mac OS X [marcpa@MarcPaquette dsl]$ cat chainWithLowerCaseIsFails.groovy def
check(condition) {
    [is: { bool ->
        println "checking if $condition yields $bool, with 'is'"
    IS: { bool ->
        println "checking if $condition yields $bool, with 'IS'"

cond = (1<2)
check cond is true
check cond IS true
[marcpa@MarcPaquette dsl]$ groovy chainWithLowerCaseIsFails.groovy checking if true yields
true, with 'IS'
[marcpa@MarcPaquette dsl]$

Marc Paquette

This email message and any attachments are for the sole use of the intended recipient(s).
Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the
intended recipient, please contact the sender by reply email and destroy all copies of the
original message and any attachments.
View raw message