第15 步:让我们继续存储和返回damage ,直到我们可以在所有功能之外使用它。
- 查看cast_spell()内部,找到fireball()和rock_smash()的函数调用。
- 在两个函数调用前添加一个返回变量来存储返回值,如下所示: damage =
此时, damage值已经从calculate_damage()到fireball()或rock_smash()并且现在在cast_spell()中!如果我们再退回一次,我们可以在MAIN CODE部分使用damage 。
To navigate the page using the TAB key, first press ESC to exit the code editor.