【已解决】if语句的疑问

Post a reply


In an effort to prevent automatic submissions, we require that you complete the following challenge.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: 【已解决】if语句的疑问

Re: if语句的疑问

Post by amnesiac » 27 Jul 2014, 19:23

首先明确 false 的含义:
单词 true 和 false 是值分别为 1 和 0 的内置变量。
接着,必须区别传统形式的赋值和表达式赋值,请参阅给变量赋值。简而言之,传统赋值使用等号,右边为原义字符串,而表达式赋值使用一组冒号等号。执行下面这两个脚本看看它们的区别:

Code: Select all

v = false
MsgBox, %v%

Code: Select all

v := false
MsgBox, %v%
若有兴趣,可以再看看这篇【风格】传统形式与表达式

【已解决】if语句的疑问

Post by gqqnbig » 27 Jul 2014, 15:04

如果我写

Code: Select all

if(false)
{
    pause
}
则pause不会被执行。

如果我写

Code: Select all

v=false
if(v)
{
    pause
}
则pause会被执行。两者结果不同。

既然我已经定义v=false了,那么if(v)应该等价于if(false)。autohotkey为什么会这样呢?

Top