Giter VIP home page Giter VIP logo

Comments (5)

RainbowMango avatar RainbowMango commented on August 17, 2024

抱歉还没来得及看,为什么又关掉了?

from goexpertprogramming.

RainbowMango avatar RainbowMango commented on August 17, 2024

那13.1节的扩容分析感觉不是问题所在,即使不扩容,只要不接收返回返回值,原来的slice也不会变化。

如果append时没有发生扩容,原来的slice也是变化的(元素增多了)。

from goexpertprogramming.

mfzzz avatar mfzzz commented on August 17, 2024

嗯,如果append没有使slice扩容,slice指向的底层数组是同一个,且里面元素发生变化。但是append是值传递,对于原slice来说,如果不接收返回值,它的len不会改变,所以底层数组的变化不会体现到它上面。所以我感觉问题不在于是否发生扩容。(这种情况 slice没有扩容,错误信息也是不会返回)。(不知道我理解的是否有偏差)

from goexpertprogramming.

RainbowMango avatar RainbowMango commented on August 17, 2024

是的,我也是这么理解的。

所以,你觉得13.1节需要改,还是13.3节需要改。建议如何改?

from goexpertprogramming.

mfzzz avatar mfzzz commented on August 17, 2024

原文“append()函数每次追加元素都有可能触发切片扩容,即有可能返回一个新的切片”,这里的“即有可能”是不是可以去掉呀,我理解的是每次都会返回新切片(即使共享底层数组的情况也算一个新切片吧?)。我觉得13.1的例子可以合并到13.3中😂。

from goexpertprogramming.

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.