Hi David, Groovy 's switch is a bit special and his beyond Java' s. Please have a look at the documentation about it. When a list is passed, it checks if the element is contained within.
Guillaume Le 7 août 2015 23:07, "KARR, DAVID" <[email protected]> a écrit : > Reading REGINA, I find this detail of Groovy semantics very curious: > ---------------------- > def myList = ['a', 'b', 'c'] > switch ('c') { > case myList: assert true;break; > default: assert false;break; > } > -------------- > > In all the languages I'm aware of with some sort of "switch/case" > construct, you can always assume that if the "case" matches, then the > "case" value "is equal to" the switch candidate. This is the first time > I've seen this not be the case. > > I certainly understand what Groovy is doing here, and I appreciate the > power of it, it's just a bit surprising. >
