FAQ
I'm curious, Jessta... When you wrote this, did Go provide the ability to
use the interface{} type?
On Tuesday, April 20, 2010 7:00:36 AM UTC-5, Jessta wrote:
On Tue, Apr 20, 2010 at 9:07 PM, Joan Miller wrote:
I know about range in map type.

But it would be easier and faster to developers that the map type
would have those built-in functions instead of to have to write them
every time that were necessary, to get an array with all keys or with
all values.
This is actually rather annoying to do with the current lack of generics.
A map can have ints or strings as a key, so a getKeys() function would
have to be written for both those types
and the values can be anything, so a getValues() function would be a mess.

Such a set of functions might be written if Go ever has generics, but
until then a for loop with range is pretty good.

- jessta

--
=====================
http://jessta.id.au


--
Subscription settings:
http://groups.google.com/group/golang-nuts/subscribe?hl=en
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Kyle Lemons at Sep 8, 2013 at 10:04 pm

    On Sun, Sep 8, 2013 at 8:13 AM, wrote:

    I'm curious, Jessta... When you wrote this, did Go provide the ability to
    use the interface{} type?
    Of course.

    Her point is that getKeys() would have to be generic or builtin unless you
    wanted to type-assert the return value, but that range works just as well
    and already exists.

    On Tuesday, April 20, 2010 7:00:36 AM UTC-5, Jessta wrote:
    On Tue, Apr 20, 2010 at 9:07 PM, Joan Miller wrote:
    I know about range in map type.

    But it would be easier and faster to developers that the map type
    would have those built-in functions instead of to have to write them
    every time that were necessary, to get an array with all keys or with
    all values.
    This is actually rather annoying to do with the current lack of generics.
    A map can have ints or strings as a key, so a getKeys() function would
    have to be written for both those types
    and the values can be anything, so a getValues() function would be a
    mess.

    Such a set of functions might be written if Go ever has generics, but
    until then a for loop with range is pretty good.

    - jessta

    --
    =====================
    http://jessta.id.au


    --
    Subscription settings: http://groups.google.com/**
    group/golang-nuts/subscribe?**hl=en<http://groups.google.com/group/golang-nuts/subscribe?hl=en>
    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 8, '13 at 9:25p
activeSep 8, '13 at 10:04p
posts2
users2
websitegolang.org

2 users in discussion

Writeme: 1 post Kyle Lemons: 1 post

People

Translate

site design / logo © 2022 Grokbase