If you want to use `is` in your DSL you could try: def check(condition) { // Define and initialize a new map def map = [:]
// Remove the `is` method from the map's metaclass map.metaClass.is = null // Add the key-value pair we care for the DSL map[is] = { bool -> println "checking if $condition yields $bool, with 'is'" } // Return the map map } I don't know if the above follows good practices or at very least is a good idea (remember that I'm very new) but it works. On Wed, Oct 28, 2015 at 12:19 AM, Edinson E. Padrón Urdaneta < edinson.padron.urdan...@gmail.com> wrote: > Well, I'm very new to groovy so I could be very wrong but `is` is a method > of `GroovyObjectSupport`, so maybe you are invoking that method in your DSL > without knowing that. > > On Tue, Oct 27, 2015 at 10:47 PM, Marc Paquette <mar...@mac.com> wrote: > >> 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 >> >> >