Need Help With Error

I’m getting this error for “greeting” in my code don’t know what do to

That is not an error, it’s just a suggestion that tells you something. If you read it, it says that you created this variable, but you never used it, meaning it will just take up memory.

OK I get that but why is it not showing “Hello You” at the top of my terminal hacker instead it just shows “greeting”

Hi Akshat,

There is a difference between greeting (the variable) and "greeting" (the string). “Hello You” is assigned to a variable. What do the parentheses of the WriteLine method contain?

I’m really new to coding so I’m not really sure what more you mean by parameters but that’s why I’ve shared these screenshots and I don’t understand why it doesn’t say “hello you” instead of “greeting” at the top of my terminal hacker

My bad. I actually meant parentheses. I fixed that in my previous answer.


The following is a method definition. The variable between the parentheses is called parameter.

void SayHello (string name)
{
    Terminal.WriteLine("Hello " + name + ".");
}

When you call the method, you have to pass on an argument. The SayHello method expects a string as an argument.

string name = "Ben";

SayHello("Rick");
SayHello(name);

// Output:
// Hello Rick.
// Hello Ben.

As you probably noticed, the syntax of my SayHello and the Terminal.WriteLine method look the same. Just the names are different.

Check your code again. What do you pass on io the WriteLine method?

And have you already compared your code to the Lecture Project Changes which can be found in the Resources of this lecture?


Please note, it’s better to copy/paste your code and apply the code fencing characters, rather than using screenshots. Screenshots are ideal for displaying specific details from within a game engine editor or even error messages, but for code, they tend to be less readable, especially on mobile devices which can require extensive zooming and scrolling.

You also prevent those that may offer to help you the ability to copy/paste part of your code back to you with suggestions and/or corrections, meaning that they would need to type a potentially lengthy response. You will often find that people are more likely to respond to your questions if you make it as easy as possible for them to do so.

Hope this helps :slight_smile:


See also;

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms