弱弱问一下,array类如何和其他类结合起来? #2632
Unanswered
xiangnanscu
asked this question in
Q&A
Replies: 2 comments 3 replies
-
luals还不支持泛型类 |
Beta Was this translation helpful? Give feedback.
0 replies
-
試出一種方式,可以用 alias + union ---上邊代碼完全相同
---@alias Array<T> array2|{[integer]: T}
---@type Array<db2>
local a = {}
-- test code
a[1]:save() -- 这里save有;类型提示
a[2]:save() -- 這個也會有
a:map() -- 这里map也会有类型提示了 ps: 是參考了這個 discussion #2586 (reply in thread) |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
我看了文档, 试了半天没有成功. 比如我有一个array2类, 我希望它成员类型是db2.
Beta Was this translation helpful? Give feedback.
All reactions