- 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.
推薦閱讀
- Implementing Modern DevOps
- Designing Machine Learning Systems with Python
- Kibana Essentials
- Python量化投資指南:基礎(chǔ)、數(shù)據(jù)與實戰(zhàn)
- 羅克韋爾ControlLogix系統(tǒng)應(yīng)用技術(shù)
- R語言編程指南
- Flash CS6中文版應(yīng)用教程(第三版)
- 嚴密系統(tǒng)設(shè)計:方法、趨勢與挑戰(zhàn)
- PLC編程與調(diào)試技術(shù)(松下系列)
- Active Directory with PowerShell
- Keras深度學(xué)習(xí)實戰(zhàn)
- Building Microservices with .NET Core
- 并行編程方法與優(yōu)化實踐
- Hack與HHVM權(quán)威指南
- Solr權(quán)威指南(下卷)