Why would the design not allow the contents of the string to be changed?  I 
understand that the size and memory allocation for it is immutable.  


On Thursday, 13 August 2020 at 18:50:10 UTC+5:30 Jan Mercl wrote:

> On Thu, Aug 13, 2020 at 3:02 PM Sathish VJ <sath...@gmail.com> wrote:
>
> > Why is this not allowed?
> >
> > s := "hello"
> > s[0] = 'a' // compile error: cannot assign to s[0]
> >
> > https://play.golang.org/p/zyJXwhEeKPo
>
> """"
> Strings are immutable: once created, it is impossible to change the
> contents of a string.
> """"
>
> (https://golang.org/ref/spec#String_types)
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/fdb397ce-4417-4c99-8774-87156d6b2412n%40googlegroups.com.

Reply via email to