关于在参数中使用"++"语句的坑,参数不改变?
今日在进行传递参数时使用了"++"语句,发现前面出现了黄色警告,然后就无视了,无奈程序就是执行不对,就回去好好看一下警告内容
The value changed at 'index++' is never used less... (Ctrl+F1)
Inspection info: This inspection points out the cases where a variable value is never
used after its assignment, i.e.: - the variable never gets read after assignment OR
- the value is always overwritten with another assignment before the next variable
- read OR - the variable initializer is redundant (for one of the above two reasons)
上面语句提示:在“index++”处更改的值的使用永远不会减少…
why?index++为先执行当前语句,再进行"++",所以是先进行传参,再"++",所以传递的参数只是原来没"++"之前的值,无语,本来以为参数中传递不算一个语句呢.虽然掉坑里了,但是又get一个知识点,这波不亏.
更改顺序后,程序正常执行,警告解除.