That's because Complex numbers are immutable - just like strings, and regular numbers for that matter.
Hence to replace one component of a complex number, you have to create a new complex number. https://go.dev/play/p/Cf06Ui6fR59 new_imag := 3.0 a = complex(real(a), new_imag) really, strings are usefully immutable so as to be keys in maps, (also utf8 encoded makes for non-editable) complex numbers as keys make no sense and would be a BIG mistake. after all complex numbers are component editable in the problem-space, and also in the underlying solution-space (hardware) so this is a nasty intermediate miss-match, seems like a mistake to me. -- 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 visit https://groups.google.com/d/msgid/golang-nuts/79f3ccd9-d7af-4a4d-a719-57212571d6c3n%40googlegroups.com.