You need to sign in to do that
Don't have an account?
SuAk
Messagemaker - Apex workbook
Hi - I try to execute the code given in the Apex work book but it does not return the string.
public class MessageMaker {
public static string helloMessage() {
return('You say "Goodbye," I say "Hello"');
}}
execute in anonymous window - MessageMaker.hellomessage();
I altered the code by changing string to void and return to system.debug, it executes the output.
What is the mistake that I am doing in the example provided?
public class MessageMaker {
public static string helloMessage() {
return('You say "Goodbye," I say "Hello"');
}}
execute in anonymous window - MessageMaker.hellomessage();
I altered the code by changing string to void and return to system.debug, it executes the output.
What is the mistake that I am doing in the example provided?
your class is perfact and calling it from anonymous window also good but when you call your apex class its return text You say "Goodbye," I say "Hello" but its not show in debug log without system.debug() for see your result try this
system.debug( MessageMaker.helloMessage() );
and now execute your code and check log and fild
22:00:08:002 USER_DEBUG [1]|DEBUG|You say "Goodbye," I say "Hello"
Thanks
Mark it best answer if it helps you :)
return statement in method never show in Debug logs until you use System.debug() in your apex class
with system.debug() you can debug your apex code and watch result so in your case if you want seen return statement in debug log try this
system.debug( MessageMaker.helloMessage() );
and find your log in debg log looks like
22:00:08:002 USER_DEBUG [1]|DEBUG|You say "Goodbye," I say "Hello"
Thanks
Mark it best answer if you clear about it :)