官术网_书友最值得收藏!

What is a method?

When we write a script, we are making lines of code that the computer is going to execute, one line at a time. As we write our code, there will be things that we want our game to execute more than once. For example, we can write a piece of code that adds two numbers. Suppose our game needs to add those two numbers a hundred different times during gameplay. So you'd say, "Wow! I have to write the same code a hundred times to add two numbers together? There has to be a better way."

Let a method take away your typing pain. You just have to write the code to add two numbers once and then give this chunk of code a name, such as AddTwoNumbers(). Now, every time your game needs to add two numbers, don't write the code over and over, just call the AddTwoNumbers() method.

主站蜘蛛池模板: 乌拉特中旗| 南川市| 内江市| 沙湾县| 象山县| 乐昌市| 白朗县| 镇平县| 中牟县| 周宁县| 乌兰浩特市| 枣庄市| 万年县| 万全县| 溧水县| 邳州市| 年辖:市辖区| 岚皋县| 黄山市| 容城县| 鹤山市| 南宫市| 百色市| 霍城县| 南岸区| 和硕县| 云和县| 郓城县| 安西县| 荥经县| 龙游县| 吴堡县| 铁岭县| 铜鼓县| 景洪市| 安庆市| 类乌齐县| 静乐县| 林州市| 曲靖市| 峨山|