FAQ
Hi there.

I want to know if anybody can explain to me, why the keyword "map" is
necessary in go.

Take these:

someList []int
someMap map[string]int

why can't the compiler simply look wheter there is something inbetween
the brackets or not? If there is something in there, it must be a map.
If there is not, it must be a list. Like in:

someList []int // Must be a list because brackets are empty
someMap [string] int //Must be a map because there is a key-datatype

Thanks in advance,
Grindhold


--
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/d/optout.

Search Discussions

  • Dmitry Vyukov at Jun 29, 2014 at 12:45 am
    is [foo]int a map (foo is a type) or an array (foo is a const)?

    On Sat, Jun 28, 2014 at 5:37 PM, Daniel Brendle wrote:
    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Hi there.

    I want to know if anybody can explain to me, why the keyword "map" is
    necessary in go.

    Take these:

    someList []int
    someMap map[string]int

    why can't the compiler simply look wheter there is something inbetween
    the brackets or not? If there is something in there, it must be a map.
    If there is not, it must be a list. Like in:

    someList []int // Must be a list because brackets are empty
    someMap [string] int //Must be a map because there is a key-datatype

    Thanks in advance,
    Grindhold


    --
    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/d/optout.
    --
    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/d/optout.
  • Carlos Castillo at Jun 29, 2014 at 9:28 am
    If you access golang-nuts through google groups there is a search
    feature: https://groups.google.com/forum/#!searchin/golang-nuts/map$20keyword

    Some relevent results:
    https://groups.google.com/forum/#!searchin/golang-nuts/map$20keyword/golang-nuts/5lQtRH0ZRo0/OoDXYXIxOr0J
    https://groups.google.com/forum/#!searchin/golang-nuts/map$20keyword/golang-nuts/O2oW7zfq4dQ/-B84Q1MhTBkJ
    On Saturday, June 28, 2014 5:38:32 PM UTC-7, Daniel Brendle wrote:

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Hi there.

    I want to know if anybody can explain to me, why the keyword "map" is
    necessary in go.

    Take these:

    someList []int
    someMap map[string]int

    why can't the compiler simply look wheter there is something inbetween
    the brackets or not? If there is something in there, it must be a map.
    If there is not, it must be a list. Like in:

    someList []int // Must be a list because brackets are empty
    someMap [string] int //Must be a map because there is a key-datatype

    Thanks in advance,
    Grindhold
    --
    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/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJun 29, '14 at 12:37a
activeJun 29, '14 at 9:28a
posts3
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase