【问题标题】:How to compare a Int64 with a Int64 [closed]如何比较 Int64 和 Int64 [关闭]
【发布时间】:2016-01-13 11:25:49
【问题描述】:

我正在编写一个 Swift 程序,但现在我遇到了一个问题:

如何比较 Int64 和 Int64?

if(msgCount.value != msg.longLongValue){

错误:

Binary operator '!=' cannot be applied to operands of type 'Int64' and 'Int64'

【问题讨论】:

  • 试试这个 if([msgCount.value compare:msg.longLongValue] == NSNotFound) OR if([msgCount.value isEqual:msg.longLongValue])。
  • 试试这个 if(![msgCount.value isEqual:msg.longLongValue])
  • 你必须用语言标记问题...大概是 swift ?
  • 它应该可以工作。请添加更多代码来说明这些值的来源。
  • 请提供一个(小)自包含示例来说明问题。您可以比较两个 Int64 操作数,因此您的代码中一定有一些特殊之处。如果没有可重复的示例,就不可能给出合理的答案,而且问题及其答案对未来的读者来说毫无价值。

标签: ios swift compare int64


【解决方案1】:

你可以直接比较是否相等

试试这个,它会帮助你:

let msgCount : Int64=100
let msg : Int64=101

if(msgCount != msg ){
    // perform your logic here.
}

【讨论】:

    猜你喜欢
    • 2019-02-12
    • 2021-03-07
    • 1970-01-01
    • 2022-01-09
    • 2015-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多