Post call gives data in the form of List<Long>
and now I have to convert it into List<String>
, so I used this approach for it:
deleteAvailablity.startDate.each {
startDateList.add(it.toString())
}
deleteAvailablity.startDate = startDateList
Is there any better approach than this?
You can use collect
:
def listOfLongs = [0L, 1L, 2L]
def listOfStrings = listOfLongs.collect { it.toString() }
assert listOfStrings == ["0", "1", "2"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With