Skip to content
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

key 为什么不支持int #135

Open
tutengdihuang opened this issue Apr 7, 2023 · 5 comments
Open

key 为什么不支持int #135

tutengdihuang opened this issue Apr 7, 2023 · 5 comments

Comments

@tutengdihuang
Copy link

No description provided.

@maxbad
Copy link

maxbad commented Apr 12, 2023

mark

@helloteemo
Copy link

helloteemo commented Apr 30, 2024

可能是因为 string 使用场景最多,所以提供 New 函数,默认key类型为 string,用来简化编程

如果要使用 int 类型作为 key 的话,可以使用 NewStringer 函数,实际使用并无差别

type Integer int

func (i Integer) String() string {
	return strconv.Itoa(int(i))
}

func main() {
	var intMap = camp.NewStringer[Integer, string]()
	intMap.Set(1, "1")
	val, ok := intMap.Get(1)
	fmt.Println(val, ok)
}

@zhiyunliu
Copy link

增加NewGeneric[K comparable, V any]它不香吗?绕来绕去的。

@helloteemo
Copy link

增加NewGeneric[K comparable, V any]它不香吗?绕来绕去的。

提PR的机会这不就来了吗?

@BruceDu521
Copy link

增加NewGeneric[K comparable, V any]它不香吗?绕来绕去的。

提PR的机会这不就来了吗?

The PR #157 submitted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants