例如,如果用户连续输入4和4,我希望看到值相同且输入的值为4
如果用户连续输入4和5,我希望看到值不同,输入的值是4,5。
在我的代码userValue
中,用户将输入并继续更改
var userValue:Int!
var outputValue:Int! = userValue
if (outputValue == userValue)
{
print("Value is same and value entered is " + String(userValue))
}
else
{
print("Values are different and values entered are ")
}
如何逐个显示用户每次输入的值,并根据上述内容做出决策?
答案 0 :(得分:1)
let fullName : String = "A,B"
let fullNameArr : [String] = fullName.components(separatedBy: ",")
var firstName : String = fullNameArr[0]
var lastName : String = fullNameArr[1]
if (firstName == lastName)
{
print("Value is same and value entered is " + String(userValue))
}
else
{
print("Values are different and values entered are ")
}
尝试这可能会有所帮助。我没有检查