268
Anon is a linguist
(lemmy.world)
This is a place to share greentexts and witness the confounding life of Anon. If you're new to the Greentext community, think of it as a sort of zoo with Anon as the main attraction.
Be warned:
If you find yourself getting angry (or god forbid, agreeing) with something Anon has said, you might be doing it wrong.
to me method names are imperatives, like when we order the dog to walk.
dog.walk() = "Dog, walk!"
I don't python, but I know there's tons of ()
why is there so much () and other empty brackets?
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:
This code would make the dog walk for 10 seconds assuming every function used is actually defined somewhere.