
def suffix = "es ate my neighbor"
println "zombi$suffix"
println 'zombi$suffix'

def regexbitch = ~/([a-z]+\/)+[a-z]*/
println "a/bc/d" =~ regexbitch
def matcher = "science bitch yeah" =~ /bitch/
println matcher

//list and iteration
("1234567" =~ /[0-9]/).each {
    println "$it"
}
println 'i' in "teaming"
println 1 in [0,1,2,3,4,5]
println (['first','middle','last'][-1] + " item")
//filter
println ( [0,1,2,3,4,5,6,7,8,9].findAll {
    it % 2 == 0
} )
//map transform
println ( [0,1,2,3,4,5,6,7,8,9].collect {
    it - 1
} )
println ( ["spread","dot","operator"]*.toUpperCase() )

//dictionary
def aKey = 'A'
def aDict = [
    (aKey) : "use var content as key",
    'B' : "normal use",
    C : "also valid use"
]
println aDict[aKey]
println aDict['B']
println aDict.C
println (
    aDict.each {
        println it.key + ':' + it.value
    }
)

//safe navigation operator
def A = {}
//println A?.B?.C
//println A?.B?.D
//elvis operator
def B = null
println B ?: "B"

//closure
def helloworld = { println "helloworld" }
helloworld ()
def fn = { payload=[], ctx={} ->
    "funnn"
}
println fn ()





//DSL
//json
import groovy.json.JsonBuilder
JsonBuilder jSon = new JsonBuilder()
jSon.records {
    a : 1
    b : 'b'
    c : "c"
    d : [1,'b',"c"]
    e : {
        A : null
    }
}
println ( jSon.toSring() )
//xml

