Examples of using range or a list in a switch statement

This are two examples of using ranges in switch statements.


def rating = 7
		def feedback = ''
		switch (rating) {
		    case 1..3 :
		    	feedback = 'good'
		    	break
		    case 3..6 :
		    	feedback = 'medium'
		    	break
		    case 6..9:
		    	feedback = 'poor'
		    	break
		    default:
		    	feedback = 'unknown'
		}

The after running the snippet feedback will be

poor
def rating = 4
		def feedback = ''
		switch (rating) {
			case [1,2,3]:
				feedback = 'good'
				break
			case [4,5,6]:
				feedback = 'medium'
				break
			case [7,8,9]:
				feedback = 'poor'
				break
			default:
				feedback = ''
		}

After running the second example feedback will be

medium