gpt4 book ai didi

ios - 在加入他们之前组织字符串以创建公共(public)房间

转载 作者:行者123 更新时间:2023-11-28 06:27:03 29 4
gpt4 key购买 nike

我正在尝试制作一个聊天应用程序,用户可以在其中聊天。我想将两个用户 uid 字符串插入函数并返回一个连接的字符串。但我希望以某种方式组织 uid,以便返回的值始终相同。

func (id1, id2) -> id1id2
func (id2, id1) -> id1id2

swift 中是否有解决该问题的高阶函数?

最佳答案

假设id1id2是字符串,你可以使用<运营商。

例如:

let id1 = "id1"
let id2 = "id2"

func conString(str1: String, str2: String) -> String {
if str1 < str2 {
return str1+str2
}
return str2+str1
}

关于ios - 在加入他们之前组织字符串以创建公共(public)房间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41561057/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com