10 Avoiding Attempt to Dereference Null Object Errors

preview_player
Показать описание
In this episode we look at 3 common ways to get - and then prevent - the "Attempt to dereference a null object" apex error

Рекомендации по теме
Комментарии
Автор

Thank you so much for sharing this very informative video

chithraprakash
Автор

Thank you very much, your explanations are very clear and makes it easier to resolve some of the issues i am facing.

neodownes
Автор

Paul, thanks again for the instructing videos. Anyway, I would like to add a small remark regarding the third method, that tries to retrieve a Person's name from the map according to its Key. Here, I think that the soultion might be highly relative according to the scenario that we want to handle. Another alternative to the aproach provided by you might be that, the method returns an empty string, in case the Key passed as input, is not included inside the map. So, the method would be rewritten in the form of:
public String example3(String s) {
return (nameMap.containsKey(s)) ? nameMap.get(key).name : '';
}
Still, leveraging null object/value as a key was a very nice insight, never thought of that.
Regards,
E.

endritsino
Автор

null as a key in Map is a nice way to go. Thanks!

andrewmuzychuk