Skip to content

Instantly share code, notes, and snippets.

@bolilla
Created April 18, 2015 10:20
Show Gist options
  • Save bolilla/75d669d338494f32f664 to your computer and use it in GitHub Desktop.
Save bolilla/75d669d338494f32f664 to your computer and use it in GitHub Desktop.
GoPadawan MethodIntPtrSlice
package main
import "fmt"
type variosEnteros []int
func (x variosEnteros) elDoble() []int {
for i, _ := range x {
x[i] = 2 * x[i]
}
return x
}
func main() {
var miArray variosEnteros = []int{1, 2, 3}
fmt.Println("miArray", miArray)
fmt.Println("y el doble es", miArray.elDoble())
fmt.Println("la variable ha cambiado", miArray)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment