- Comprehensive Ruby Programming
- Jordan Hudgens
- 223字
- 2021-07-02 21:13:33
What are method arguments?
Before we can get into the code examples, let's first walk through what method arguments are. Let's begin with a real-world example:

Imagine that you have a machine that makes baseball bats. The workflow for the bat making process would be as follows:
- The raw wood is placed in the machine.
- From there, the machine takes the wood, cuts, and polishes it.
- Lastly, it finishes off by giving the output as the finished baseball bats from the machine.
So let's see how this analogy applies to the methods in Ruby:

- Method arguments: The raw wood placed inside the machine represents the method arguments. This is the data that can be provided by a user, a database query, an API, and so on. It is rare for a method not to have arguments, since method arguments are what allow for dynamic behavior. Looking back at our example, would it be possible to produce the baseball bats if we didn't first supply the machine with the raw materials? Of course not. In the same way, methods need data in order to work with.
- The method: The machine itself represents the method. This is where the actual logic goes that will produce the desired behavior.
- The returned values: Lastly, the finished bats are like the values that get returned by the methods.
推薦閱讀
- Java Web程序設計
- 高級C/C++編譯技術(典藏版)
- 精通網絡視頻核心開發技術
- 琢石成器:Windows環境下32位匯編語言程序設計
- Serverless架構
- 打開Go語言之門:入門、實戰與進階
- .NET 4.5 Parallel Extensions Cookbook
- PhoneGap 4 Mobile Application Development Cookbook
- Java 9 with JShell
- 深入淺出 HTTPS:從原理到實戰
- Mastering R for Quantitative Finance
- Java網絡編程實用精解
- 情境微課開發(第2版)
- 自學Python:編程基礎、科學計算及數據分析
- C#程序開發教程