Giter Club home page Giter Club logo

Comments (1)

hayden-pan avatar hayden-pan commented on July 3, 2024

是的,原题解释是有问题的,但是在这个项目里的另一个地方有同样的一道题,解释却是对的了。大概意思也是vscode智能提示里的错误,就是map索引读出是不可以获取到地址的。这里第一个回答解释了。这应该是golang故意设计的,因为如果暴露了值的地址,那么用户可以取这个值的地址进行传播,但是当map进行扩容的时候,值的存储地址就会被移动,那么原来的地址会失效。

但是有一点我却不是很理解,同样是在扩容的时候值的地址会变化的slice数据结构,为什么索引取值的时候却可以取地址?而不是和map一样的设计呢?当然如此这样设计,在编写代码的时候就显得很麻烦了

from interview-go.

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.