• yetAnotherUser@discuss.tchncs.de
        link
        fedilink
        arrow-up
        8
        ·
        edit-2
        1 day ago

        It’s calling a function without a parameter.

        You know how in math you had something like:

        f(x) = x²

        Not all functions need parameters though. The function:

        f(x) = 2

        does not even use the provided x! So just leave it out:

        f() = 2

        Similarly, you could give a function two parameters:

        f(x, y) = x + y

        Programmers use functions to primarily organize their code. Otherwise it would get very unreadable very quickly. Those function are usually a bit more complicated than a single line, though.

        dog.walk() would call the walk() function of “dog”. Some valid code could be:

        dog.walk()
        wait(10)
        dog.stop()
        

        This code would make the dog walk for 10 seconds assuming every function used is actually defined somewhere.