- January 4, 2020 at 22:53 #16455
I have a quetion about the “Function” video, in this section, 20:23.
Why we need to assign “rot = 0”? But when it only have i and k in the paremetic don’t need to.
According to error information, why we need to procedure the function twice? What is the meaning of overload?
- January 5, 2020 at 22:45 #16482Reinhard KoenigKeymaster
Dear Ruo-Xuan Wu,
the additional parameter “rot=0” gives you the option to send this parameter to your function if you’d like to change it (use something else than 0). But if you don’t like to change it you can just ignore this parameter, since it is set to 0 already. In case you never want to use the rotation parameter rot, you don’t need it, but I showed it for an example of how you can add optional parameters (=parameters that you may use or not).
- January 5, 2020 at 22:51 #16485
I can understand we need a “rot” to receive the number from main function.
But it’s unclear for me that “i” and “k” both don’t need it, only we create a new parameter “rot” need to be overloaded.
- January 5, 2020 at 23:02 #16486Reinhard KoenigKeymaster
Usually, you need to send values for parameters that you define for the input of a function (as i and k in our example). That’s the most often used variant. But you can use optional parameters as inputs as well (after the obligatory parameters). When you call the function, you can decide if you change the optional parameters or not. That’s not possible with the “normal” parameters as i and k.
Maybe other explanations may be helpful:
I hope this helps you understand the concept of optional parameters.
- January 5, 2020 at 23:10 #16487
Thank your for your explanaiton, I think dicuss face-to-face tomorrow would be more easily to understand :).
- You must be logged in to reply to this topic.