1

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]]
shrishinde
  • 3,219
  • 1
  • 20
  • 31

1 Answers1

2
options_str = "test_suite test_suite_name email emialid job_name test_job"
split_option = options_str.split()
println split_option.collate(2)
shrishinde
  • 3,219
  • 1
  • 20
  • 31
  • after I put together my question, I found answer so thought of posting it. – shrishinde Jan 21 '20 at 13:27
  • collate is deprecated for list/array. In case you need such function refer this answer https://stackoverflow.com/a/2926548/3720085 – shrishinde Jan 24 '20 at 05:13
  • collate is deprecated for list/array. In case you need such function refer this answer https://stackoverflow.com/a/2926548/3720085 – shrishinde Jan 24 '20 at 05:13