Contact: aviboots(AT)netvision.net.il
39,851 questions
51,772 answers
573 users
package main import ( "fmt" ) type S struct { x, y float64 } func (st *S) Add(f float64) { st.x = st.x + f st.y = st.y + f } func main() { st := S{2, 7} st.Add(10) fmt.Println(st.x, st.y) } /* run: 12 17 */
package main import ( "fmt" ) type S struct { x, y float64 } func f(st *S, f float64) { st.x = st.x + f st.y = st.y + f } func main() { st := S{3, 8} f(&st, 10) fmt.Println(st.x, st.y) } /* run: 13 18 */
package main import ( "fmt" ) type S struct { x, y float64 } func (st *S) Add(f float64) { st.x = st.x + f st.y = st.y + f } func main() { st := &S{4, 6} st.Add(10) fmt.Println(st.x, st.y) } /* run: 14 16 */