function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SuAkSuAk 

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?

 
sfdcMonkey.comsfdcMonkey.com
hi sujatha ArvindKrishnan
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 :)
SuAkSuAk
My question is return statement cannot be seen in Debug logs ?
sfdcMonkey.comsfdcMonkey.com
hi sujatha
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 :)