You need to sign in to do that
Don't have an account?
MarkInAtlanta
MultiColumn Array
Kind of a simple issue (i think). I have an Apex Class that i want to build a multi-column array to use later.
something along the line of:
List<Id, string, double> 3ColumnList = new List<Id, string, double>();
This is not legal since the list wants a single type.. How would one handle an internal table or array like this in Apex?
Im trying to get some processing out of the loop and handle it in a more bulkified manner. I dont have an object that matches the array description although i guess I could "borrow" an existing object type.. Seems like a hack to do that though..
something along the line of:
List<Id, string, double> 3ColumnList = new List<Id, string, double>();
This is not legal since the list wants a single type.. How would one handle an internal table or array like this in Apex?
Im trying to get some processing out of the loop and handle it in a more bulkified manner. I dont have an object that matches the array description although i guess I could "borrow" an existing object type.. Seems like a hack to do that though..
Learn about Maps. Maps are an orderd, collection of a key/value pair. So you could create two maps, one to hold the id/string key/value pair, and one to hold the id/decimal key/value pair. They would be defined like this...
If you're just dealing with the two pieces of information - then that's probably okay. But if you have more piences of information that needs to be kept for the Id, then you might want to look at a wrapper class to hold the info.
All Answers
Learn about Maps. Maps are an orderd, collection of a key/value pair. So you could create two maps, one to hold the id/string key/value pair, and one to hold the id/decimal key/value pair. They would be defined like this...
If you're just dealing with the two pieces of information - then that's probably okay. But if you have more piences of information that needs to be kept for the Id, then you might want to look at a wrapper class to hold the info.
Little more work to handle the delimited string but i already have a set of utility methods that deconstruct/deconstruct a delimited string so all i need to add is a method to iterate over the map and return the array of fields.