查看: 1688|回复: 2

[已经解决] 请问:表达式的计算顺序

[复制链接]
梦石
0
星屑
4761
在线时间
285 小时
注册时间
2013-10-13
回帖
580
发表于 2022-7-10 16:12:37 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
  #----------------------------------------------------------
  # ● 设置 MaxHP
  #     maxhp : 新的 MaxHP  
  #----------------------------------------------------------
  def maxhp=(maxhp)
    @maxhp_plus += maxhp -  self.maxhp
    @maxhp_plus = [[@maxhp_plus, -9999].max, 9999].min
  end
请问:上面的第一个表达式的计算顺序是什么样子的?是先@maxhp_plus +  maxhp 然后再-  self.maxhp 还是先maxhp -  self.maxhp然后@maxhp_plus+(maxhp -  self.maxhp)?
梦石
0
星屑
8003
在线时间
1184 小时
注册时间
2007-7-29
回帖
2014
发表于 2022-7-11 00:56:02 | 显示全部楼层
  1. @maxhp_plus += (maxhp -  self.maxhp)
复制代码

评分

参与人数 1星屑 +50 收起 理由
RyanBern + 50 认可答案

查看全部评分

回复

使用道具 举报

梦石
0
星屑
9160
在线时间
466 小时
注册时间
2015-5-8
回帖
704
发表于 2022-7-11 04:38:03 | 显示全部楼层
先maxhp -  self.maxhp然后得出的值给@maxhp_plus加上
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部