println '######################## List ##########################\n'
List<Integer> list = [1,2,3,4,5,6,7,7,6,5,6,7,5,6,5]
println 'value list[0] is '+list[0]
println 'value list[3] is '+list[3]
println 'value list[8] is '+list[8]
println 'size = '+list.size()
println '######################## MAP ##########################\n'
Map map = [:]
def map2 = ["Jim":"Knopf", "Thomas":"Edison"]
println map2["Jim"]
map2["Test"] = "Tester"
println map2["Test"]
println '######################## For ##########################\n'
for (i in 0..9) {
println ("Hello $i" )
}
println '######################## Defines a string with special signs ##########################\n'
// Defines a string with special signs
def text = "John Jimbo jingeled happily ever after"
// Every word must be followed by a nonword character
// Match
if (text==~/(\w*\W+)*/){
println "Match was successful"
} else {
println "Match was not successful"
}
// Every word must be followed by a nonword character
// Find
if (text=~/(\w*\W+)*/){
println "Find was successful"
} else {
println "Find was not successful"
}
if (text==~/^J.*/ ){
println "There was a match"
} else {
println "No match found"
}
def newText = text.replaceAll(/\w+/, "hubba")
println newText
No comments:
Post a Comment