On Thu, Aug 18, 2016 at 9:32 AM, <alexanderya...@gmail.com> wrote:

> func Pic(dx, dy int) [][]uint8 {
> pic := make([][]uint8, dy)
> for i := 0; i < dy; i++ {
> pic[i] = make([]uint8, dx)
> for j := 0; j < dx; j++ {
> pic[i][j] = uint8(float64(i)*math.Log(float64(j)))
> }
> }
> return pic
> }
>
> [][]uint8 is not an array: it's a slice of slices.

OP asked for a 3x3 array.
one can create such a beast like that:
 https://play.golang.org/p/n0warBR7Pn

hth,
-s


> 在 2010年5月5日星期三 UTC+8上午12:30:56,Yang Yang写道:
>>
>> Hi, All
>>
>> I'm new to Go programming language. I want to initialize a two
>> dimension array.
>> But I cannot find how to do it in the document.
>> Is there a way to initialize [3][3]int in declaration.
>>
>> Best regards
>>
>> Yang
>>
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to