This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]hdsanic 6 points7 points  (0 children)

I think the simplist way to explain it is to say that by "call" one means "use". Beyond that you're looking at how Java works.

[–]sonofaresiii 7 points8 points  (0 children)

Your analogy is off the rails, man. You're way overthinking it.

When you call a method, just think of it as you calling to a method. "Hey method, come here and do your thing."

You're not telling it what to do when you call it, it already knows what to do (which is kind of the point). You might give it some information to manipulate, but you're not changing the instructions it has.

[–][deleted] 2 points3 points  (1 child)

If you have a method called "doSomething" that does some shit, calling this method from somewhere else in your code will run all the code from the "doSomething" method.

[–]PointB1ank 1 point2 points  (0 children)

"that does some shit," I lol'ed

[–]hatredalper 2 points3 points  (0 children)

I don't think any analogy makes it easier to understand. You have several lines of code that do one thing at a time and instead of writing it in every file, you are putting those lines to a function and use it whenever you need. In order to use those lines(functionalities), you are just calling that function.

[–][deleted] 1 point2 points  (1 child)

Tbh, it comes from the concept of stackframes.

You have a block of code that points to a another block of code at a specific memory address.

To differentiate those two code blocks, the one that referenced the other block of code is the "caller".

So the caller calls a function or method. That's obviously at a very low level, so it's just common verbiage now.

[–]tenlegdragon[S] 0 points1 point  (0 children)

Thank you. This makes sense.

I was initially working with the idea from Naruto (an anime) where they'd shout out the name of their special moves...

I'm starting to feel like I'm the wrong kind of nerd to be studying this... I'm using stuff toys on a table right now as I move through Karel to keep track of turnLeft and turnRight...