Thoughts and worries after questionnaire at end of Section 2

This is my first entry here, I’m not sure if I’m breaking the rules when not asking directly about code but rather having some thoughts after the questionnaire and what I’d learned so far.

So, about the questionnaire at the end of section 2.

The curly brackets { } were only briefly touched on as to their exact function. I felt like they were going to be explained more as we went on, and that I was gaining an understanding slowly, but as of the questionnaire had not understood them fully (even when rewatching).

The void keyword was barely mentioned at all so far and I definitely did not gain an understanding of it or when to use it. It doesn’t return something. What IS return? Return what, where? I’m completely new to programming and do not understand these terms.

In the question about taking in float and returning int the code was formated in a way that, again, felt just one step above what I’d done so far. A bit like learning addition and subtraction and having multiplication thrown into the quiz.

Overall it felt like the questionnaire asked questions one level (even if still at a beginners level) above the understanding I had after completing the Number Wizard game.

Up until now I thought I was going at a beginners pace and doing well since I was keeping up, could experiment a little in the code, when suddenly this curve ball comes along and says I should understand these things at the end of section 2 when I do not.

Now I’m wondering if, when continuing, I’m just a dummy and this is obvious to everyone else?

1 Like

Hi @Tomas_Andersson, as it’s your first post I would like to welcome you to the community and also assure you that you are not breaking any rules - if you have questions, please do ask :slight_smile:

Responding to each of your points in turn;

The curly brackets { } were only briefly touched on as to their exact function. I felt like they were going to be explained more as we went on, and that I was gaining an understanding slowly, but as of the questionnaire had not understood them fully (even when rewatching).

The curly braces in C# are used to indicate blocks of code. To give you an example of how they may be used;

if (myName == "Rob") 
    {
        Debug.Log("Hi Rob!");
    }
else
    { 
        Debug.Log("Erm... you're not Rob?");
    }  

The above is referred to as an if statement, used for testing some logic. The curly braces used above indicate a block of code for each condition, e.g. whether the myName variable equals Rob or not. Anything within one of these code blocks will be run under the appropriate condition.

The void keyword was barely mentioned at all so far and I definitely did not gain an understanding of it or when to use it. It doesn’t return something. What IS return? Return what, where? I’m completely new to programming and do not understand these terms.

This may be a little soon for my more detailed explanation, but lets go for it! :slight_smile:

You code is placed into classes, these are used as templates or, cookie cutters, for creating objects (instances of classes). These classes may well have behaviours, we would refer to these as methods.

If you think of yourself as an instance of the Human class, you have specific behaviours. For example, you can Sit, Stand, Run, Greet a friend.

We may create methods to represent these behaviours. Some of these methods would just need to do something, but not necessarily provide a value or response back to whatever called them. For example;

public void Run() {
    // code for running goes here
} 

The method Run() is an example of a void being used. void is a Type, however it indicates that the method doesn’t return a value to whatever call it.

So, what about something that does return a value and use the return word that keeps getting mentioned… lets take your Greet a friend behaviour;

public string GreetFriend() {
    string greeting = "Hello friend, long time no see!";

    return greeting;
}

In the above example, rather than void I have used a string (as we will be returning some words).

Within this method I create a variable called greeting which is also of Type string. I also populate it with a value, that is the part in the quotation marks.

Below this you can see the return keyword, followed by the variable. So, when this method is called, it will return the value of the greeting variable to the calling code. In a real world example, perhaps this is a message that is displayed to the user when they first start the game.

In the question about taking in float and returning int the code was formated in a way that, again, felt just one step above what I’d done so far. A bit like learning addition and subtraction and having multiplication thrown into the quiz.

I don’t recall this specific item, but I suspect it may have been something like this;

(int)maximumSpeed;

Assuming so, the (int) in front of the variable name maximumSpeed casts the maximumSpeed variable from being of Type float to Type int - it has changed it’s type (it’s class). In this specific example you would be taking a number with a floating point and converting it to a whole number (and integer).

Up until now I thought I was going at a beginners pace and doing well since I was keeping up, could experiment a little in the code, when suddenly this curve ball comes along and says I should understand these things at the end of section 2 when I do not.

The fact that you have been feeling that way is fantastic, and I would really recommend to not lose sight of that. Everyone will have varying strengths/weaknesses/experiences and so on, things that are perhaps more straight forward to one person will not necessarily be to the next person. You only have to search on the forum to see the number of questions that come up for all sorts of things and at all sorts of levels.

Now I’m wondering if, when continuing, I’m just a dummy and this is obvious to everyone else?

Absolutely not a dummy! You have proven this by giving things a go yourself, stepping out of the comfort zone, you can’t expect to understand everything straight away, I don’t believe anyone can, I certainly never have. Give yourself some credit for what you have achieved so far and, the fact that you felt comfortable enough to ask some questions on the forum - not everyone does, yet everyone’s questions are so valuable. For all you know there may have been another half a dozen people wondering the same thing but didn’t have the courage to ask, your question will have now also helped them and hopefully also given them a little more confidence to ask questions.

If there is anything in my examples or explanations above which doesn’t make sense, please do ask and I will do what I can to help you :slight_smile: Once again, welcome to the community :slight_smile:


See also;

2 Likes

hi Tomas,

tell you what, you made the first step that most people arent confident in doing, or dont want to do … and thats asking questions :slight_smile: so brilliant stuff on that point!

stick with it, it will get clearer and by Robs reply shows, it is a great community here. were all in the same learning boat and always around and willing to help each other out…

3 Likes

Thank you for both your answers. I’ll definitely keep on with the course, I was just a bit worried that I was not getting it.

The (int) I was befuddled with in the quiz, even though I made a guess and got it right, was this:

int MyMethod (float myNum) {}

Whereas in the previous lesson’s we’d only ever defined a new variable (sorry, don’t have the lingo down) and later assigned a value to it. So I was pretty taken aback.

But, I’m encouraged by your replies and will, as I said, keep on trucking. Thank you both again.

2 Likes

You are more than welcome @Tomas_Andersson

int MyMethod (float myNum) {}

This one is, as I am sure you know now, a method, as per my example above it is returning a value of Type int. In this specific wxample it also has a parameter of Type float being passed into the method called myNum.

You may have noticed that this one doesn’t start with public or private, these are what are referred to as Access Modifiers which control what can see and access the variables, properties or methods. By default, if they are not included, private is assumed.

Glad to hear you’ll keep on trucking and feel free to post if there is anything else. :slight_smile:

1 Like

Privacy & Terms