ruby – 和|和|之间的差异设置变量时
发布时间:2020-12-16 21:16:21 所属栏目:百科 来源:网络整理
导读:我的印象是||或者是同义词. 设置变量有或没有值;为什么? test = nil or true= true test= nil test = false or true= true test= false 使用||“按预期”工作 test = nil || true= true test= true 解决方法 或者优先级低于=. test = nil or true 是相同的
我的印象是||或者是同义词.
设置变量有或没有值;为什么? >> test = nil or true => true >> test => nil >> test = false or true => true >> test => false 使用||“按预期”工作 >> test = nil || true => true >> test => true 解决方法
或者优先级低于=.
test = nil or true 是相同的 (test = nil) or true 这是真的,同时将测试设置为零. ||优先级高于=. test = nil || true 是相同的 test = (nil || true) 这是真的,同时将测试设置为true. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |