Skip to content

Instantly share code, notes, and snippets.

@swapnilshrikhande
Created May 31, 2020 13:49
Show Gist options
  • Save swapnilshrikhande/1071aad7c6e9c0eeafa4c937b26795aa to your computer and use it in GitHub Desktop.
Save swapnilshrikhande/1071aad7c6e9c0eeafa4c937b26795aa to your computer and use it in GitHub Desktop.
Apex Join
String join(List<String> values) {
List<String> valueCopy = new List<String>(values);
if(valueCopy.isEmpty())
return null;
String result = valueCopy[0];
valueCopy.remove(0);
while(!valueCopy.isEmpty()) {
result += ',' + valueCopy[0];
valueCopy.remove(0);
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment