Beware the difference between split & tokenize

Galeon Post in Groovy & Grails, Note to myself
0

There is a little difference between tokenize and split in Groovy:

def csv = "1,,3,4,5"

println csv.split(",")
println csv.tokenize(",")

results in

[1, , 3, 4, 5]
[1, 3, 4, 5]

Note that tokenize ignores the empty element.

Edit: I just found this blog-post covering the same topic

« Prev: :Next »

Leave a Reply