fork download
  1. def lista = ['01.um','02.dois','03.tres']
  2.  
  3.  
  4. //opcao 1
  5. assert lista.collect {it.take(2)} == ['01','02','03']
  6. assert lista*.take(2) == ['01','02','03']
  7.  
  8. //opcao 2
  9. assert lista.collect {it.tokenize(".").first()} == ['01','02','03']
  10.  
  11. println "Teste Ok!"
Success #stdin #stdout 1.43s 332928KB
stdin
Standard input is empty
stdout
Teste Ok!