What is the point in returning the string, cause when I remove the method I can still see and type in the question in the inspector. I know returning can terminate a code block, but I’m wondering what returning the string does.
Hi,
“Returning a string” returns a string and terminates the method. Apart from that, it does not do anything.
When you call, for example, GetInstanceID(), which is a Unity method, that method returns an integer. You can assign the returned int value to a variable.
int id = GetInstanceID();
string question = yourVariable.GetQuestion();
int userID = 12345;
string username = someVariable.GetUsername(userID);
Calling methods on the right-handed side works with “return” methods only because we cannot assign “nothing” to a variable.
Is this what you wanted to know?
See also:
- Forum User Guides : How to mark a topic as solved
1 Like
Thanks I think I understand a bit more now!
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.