shrishinde
shrishinde

Reputation: 3405

extract pairs from groovy list

I am new to groovy.

Is there way to get elements from list as pairs.

options_str = "test_suite test_suite_name email emialid job_name test_job"
split_option = options_str.split()
println split_option

Current output:

[test_suite, test_suite_name, email, emialid, job_name, test_job]

Expected output:

[[test_suite, test_suite_name], [email, emialid], [job_name, test_job]]

Upvotes: 1

Views: 69

Answers (1)

shrishinde
shrishinde

Reputation: 3405

options_str = "test_suite test_suite_name email emialid job_name test_job"
split_option = options_str.split()
println split_option.collate(2)

Upvotes: 2

Related Questions