On Saturday 9 November 2024 at 00:25:21 UTC simon place wrote: but whereas you can read a component...
real com.:=Real(cmplx) imaginary com.:=Imag(cmplx) i can't see any way to write to a component. 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) -- 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/f9fbd79a-334d-462e-9b7a-7bcebd3025a1n%40googlegroups.com.