sasiatecs
8 years agoNew Contributor
Strange behaviour with groovy script
def countries = ['IND':'India', 'USA':'United States of America', 'PAK':'Pakistan', 'AUS':'Australia' ] //Printing map log.info "Before : $countries" String countryIamLookingFor boolean foundCountry countryIamLookingFor = 'SIG' foundCountry = countries.containsKey(countryIamLookingFor) log.info "Found Country $countryIamLookingFor : $foundCountry" String countryName = countries.get(countryIamLookingFor) if(foundCountry){ log.info "Country name is $countryName" }else{ log.error "Sorry! Country not found" } //Printing map log.info "Before : $countries" countries.put('NZ','Newzealand') log.info "After : $countries"
When I run this script, "Newzealand is getting printed at "
log.info "Before : $countries"