Giter VIP home page Giter VIP logo

Comments (3)

flycash avatar flycash commented on September 27, 2024 1

没有 ToMap 这个方法吧?在mapx 下有一个。这里我是准备放过去 slice 包里面的。

另外顺序的话,因为考虑到有 Val 和没有 Val 两个版本,并且我希望 Key 和 Val 挨着,所以只能是 Ele 在最前,或者 Ele 在最后。

from ekit.

dxyinme avatar dxyinme commented on September 27, 2024

这里的Key是否该为comparable

改了一下函数泛型顺序,可以改成这样,然后repo内部已经存在ToMap函数了,可能函数名也得改改

// 如果 eles 是 nil,那么返回一个空的 map 而不是返回 nil
func ToMapWithE2KFunc[Key comparable, Ele any] (eles []Ele, E2KFunc func(ele Ele) Key) map[Key]Ele
// 命名无能,你可以搞一个更加牛逼的名字。
func ToMapWithE2KVFunc[Key comparable, Ele any, Val any] (eles []Ele, E2KVFunc func(ele Ele) (Key, Val)) map[Key]Val

from ekit.

dxyinme avatar dxyinme commented on September 27, 2024

没有 ToMap 这个方法吧?在mapx 下有一个。这里我是准备放过去 slice 包里面的。

另外顺序的话,因为考虑到有 Val 和没有 Val 两个版本,并且我希望 Key 和 Val 挨着,所以只能是 Ele 在最前,或者 Ele 在最后。

那我理解了,开搞

from ekit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.