![]() Q: What happens if the argument you want to pass is an object instead of a primitive?Ī: You’ll learn more about this in later chapters, but you already know the answer. And that something must be a value of the appropriate type. A variable with a type and a name, that can be used inside the body of the method.īut here’s the important part: If a method takes a parameter, you must pass it something. And a parameter is nothing more than a local variable. An argument (a value like 2, “Foo”, or a reference to a Dog) lands face-down into a. A caller passes arguments.Īrguments are the things you pass into the methods. ![]() So you can call them whatever you like (arguments, donuts, hairballs, etc.) but we’re doing it like this:Ī method uses parameters. ![]() Although there are formal computer science distinctions that people who wear lab coats and who will almost certainly not read this book, make, we have bigger fish to fry in this book. You might, for example, want to tell a Dog object how many times to bark by calling: d.bark(3) ĭepending on your programming background and personal preferences, you might use the term arguments or perhaps parameters for the values passed into a method. Just as you expect from any programming language, you can pass values into your methods.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |