Groovy flexible way of replaceAll method -
i new groovy , thats why can't figure 1 thing out. have ant task groovy class supposed read lines property file , switch of property.values, example 1 "one", 2 "two" etc. have extracted values i've got 1,2,3 etc or 5,7,1 , problem starts know replaceall method, possible somehow make more flexible? or if want change 1 2 3 have define 3 replaceall methods ("1", "one") ("2","two") ("3", "three") ? oh , yes, switch values on output.
you use collect , switch (assuming understand question:
def = [ 1, 4, 2 ] def b = a.collect { switch( ) { case 1 : 'one' ; break case 2 : 'two' ; break case 3 : 'three' ; break default : } } assert b = [ 'one', 4, 'two' ] // , other way def c = b.collect { switch( ) { case 'one' : 1 ; break case 'two' : 2 ; break case 'three' : 3 ; break default : } } assert c ==
Comments
Post a Comment