Created
December 27, 2013 04:59
-
-
Save reiver/8142758 to your computer and use it in GitHub Desktop.
One way of copying between arrays of different sizes, in #golang (i.e., Go). Is this the most efficient way of doing it?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
var a [9]uint8 | |
fmt.Printf("a = %v\n", a) | |
b := [3]uint8{1, 2, 3} | |
copy( a[0:3] , b[0:3] ) | |
fmt.Printf("a = %v\n", a) | |
c := [3]uint8{4, 5, 6} | |
copy( a[3:6] , c[0:3] ) | |
fmt.Printf("a = %v\n", a) | |
d := [3]uint8{7, 8, 9} | |
copy( a[6:9] , d[0:3] ) | |
fmt.Printf("a = %v\n", a) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment