On 17 Sep 2016 12:31 p.m., <oyi...@gmail.com> wrote: > > Context enables homonyms in spoken languages and overloaded or polymorphic notation in mathematics. Types do the same in programming languages. The rationale for + over join() or cat() for string is equally applicable to slices.
1+1 give you a new number that doesn't modify the original numbers being added. This is the expected way addition works. In Go this also works for strings, "a"+"b" gives you "ab" and the original strings are unmodified. For slices this is different, two slices can refer to the same backing array so slice1 + slice2 could either allocate a new slice and copy both slices in to it, or it could modify slice1 by appending slice2. If slice1 and slice2 refer to the same backing array, their addition could change both of the original values, this addition can also effect slice3 that happens to also reference the same backing array. append() isn't addition because of these properties. -- 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. For more options, visit https://groups.google.com/d/optout.