-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tuple: 新增 Pair 和 Triple 两种类型 #161
Comments
当前实现中toList/toArray的使用场景是什么? First,Second,Third本身不就表示了逻辑上的“list/array”有顺序的概念了吗?
|
可以直接提合并请求,这样我们比较好 review 代码 😄 |
没勇气提pr啊.... |
怕什么,大不了被拒 [滑稽] |
还是直接发 PR,我们比较好管理 |
感觉对于Pair的函数定义来说,Copy应该还是用于复制自身,然后需要一个MergeFrom来更新会比较好 |
Merged
Pair 已经解决了,等后面有需要的时候,再来解决 tuple 的问题 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
仅限中文
使用场景
行业分析
主要参考
Kotlin
和Python
中的tuple
Kotlin
官方文档 Pair 和 Triple,其官方示例如下所示
都实现了
Serializeable
接口;可以单独获取每个位置的值;支持将其转为String
和List
;额外支持使用
.copy(first=3)
的方式复制并修改值Python(3.11)
官方文档,特点如下:
可行方案
目标
.copy()
来显式(复制)更改值包结构
最开始是打算第一层用
tuple
包,然后再下接pair
和triple
的,但是发现这样存在一个很明显的问题:没必要这么设计:
不会存在
ekit.tuple(a,b,c)
和ekit.tuple(a,b)
混用的情况,而且这样设计也容易混淆pair
和triple
更多的值?
也就是支持列如
quadra(a,b,c,d)
的内容:没有这个必要,如果有这么多的值的需求应该自己创建一个数组来解决
支持的类型
和
map
不一样,不存在需要做比较之类的操作,所以支持any
但是因为涉及到序列化toString()
和toList()
,所以需要特殊处理一些类型直接使用
fmt
包和[]any
就可以了。所以不限制类型关于 nil
在 Kotlin 中,Value 是可以为 null 的,但是设为 null 之后不可更改
这样可能不方便使用,故不参考
其它
期待的代码示例
The text was updated successfully, but these errors were encountered: