Solidity ++ 运算符未按预期分配

问题描述

很抱歉完全重写这篇文章,但我的故障排除还很遥远。希望这可以防止将来有人头痛...

现在,例如代码

    function compare(uint8 a,uint8 b)
    private
    requireUnpaused
    returns(bool)
    {
        // increment a by 1
        a = a++;
        // if a + 1 = 3,then loop it around the cycle to be 0
        if (a >= 3) {
            a = 0;
        }
        // compare a to b.  If a = b,a is the winner - return true
        return a == b ? true : false;
    }

如果我将“a = a++”替换为“a = ++a”,仅替换“a++”或“++a”,甚至“a = a + 1”,则此代码按预期工作。

这让我疯狂了几天。我问一个比我更精通这个的人的问题:为什么“a = a++”不起作用,而将“a”增加 1 的所有其他方式都有效?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)