Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a parameter list with undefined parameters messes with my brain #987

Open
laserbeak opened this issue Sep 13, 2024 · 1 comment
Labels
content Issues with the lessons, practices, including their code examples

Comments

@laserbeak
Copy link

Issue description:
Creating a parameter list with undefined parameters messes with my brain
In my mind, this code should generate an error.
I really struggled with the idea that I could just put "length" as a parameter without having to define it.

Let's make our square drawing function more flexible
to include rectangles of varying sizes.

Your job is to code a function named
draw_rectangle () that takes two parameters: the
length and the he ight of the rectangle.

The turtle should face towards the right when
starting or completing a rectangle.

Note that we could still draw a square with
draw_rectangle () by having the length and
height equal the same value.

func draw_rectangle(length, height): move_forward(length) turn_right(90) move_forward(height) turn_right(90) move_forward(length) turn_right(90) move_forward(height) turn_right(90)

@laserbeak laserbeak added the content Issues with the lessons, practices, including their code examples label Sep 13, 2024
@huntmckay
Copy link

If this is related to the https://gdquest.itch.io/learn-godot-gdscript cute little turtle game:

Imagine you are creating tests for your function, you would want the parameters to accept any value within your definition. The goal of the tutorial is to abstract some of this away from the user. It doesn't really matter what length or height equal, just that its clear to the user it going to be an int. Rectangles [subsequently squares], have 4 - 90 degree angles and sides. func draw_rectangle() always needs to run turn_right(90) to accept to create the correct shape. Even if we abstracted func turn_right(angle) angle would always equal 90 to produce a 4 sided rectangle. It's more confusing this way, because the new student might ask "why is the angle abstracted?"

Now from a technical argument, func draw_rectangle() could actually draw any shape, but that's a bad habit I think the tutorial is guiding you away from by providing such assignments and definitions. I think this is some pythonic influence as well, because all the function really says is "I need to parameters to execute" there is no type hinting or assertion as far as we can see in the gamified interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content Issues with the lessons, practices, including their code examples
Projects
None yet
Development

No branches or pull requests

2 participants