Am I your type?
Welcome back to Week Four of “Learning to Speak Like A Developer (Or at least Fake It at Dreamforce).” If you’ve been here for the past three weeks, you are well on your way already! If not, go read those other three posts & catch up. Today’s post is a bit different, because it’s not strictly a vocabulary lesson. There’s a bit more ‘meat’ to it, so strap in!
In Apex, all variables and expressions have a data type. I’ve got a bit of a surprise for you. Unbeknownst to you, I’ve taught you two data types already! So far, you’ve learned about sObjects and objects. Hopefully, you’ve got those two down, so let’s talk about the rest.
Primitives – This is probably the type that you are most familiar with. If you think in terms of Salesforce, you can almost imagine these as some of the field types you can create – boolean (checkbox), integer or decimal (number), date, ID, string (text).
Collections – Just like they sound, groupings of elements. These elements can be sObjects, objects, primitives of other collections. They can be a set – an unordered grouping with no repetition of elements. They could also be a list, which is an ordered grouping of elements. They can also be a map, which is where a unique key will map over a value.
Enum – The best way to explain these are that they are a hard-coded set of values. They are used to define a set that has no particular order of the values within it.
Null – This one is pretty self-explanatory.
So there you have it – data types in Apex. If all (or even some) of this is making sense, you are already on the path to becoming a developer. And for now, you can fake it & impress 70% of the people at Dreamforce. And seriously, if you haven’t registered yet, what the heck are you waiting for? Just register, come see me speak about my journey from clicks to code & maybe get some free swag from yours truly!
Speaking of swag — what’s your favorite thing to get at a tradeshow? Favorite big item (think electronics), or favorite little item (think bling or something to give the kiddos)? I’ve got some things cooking, but I’d love to hear from my readers!