Commit 8055f470 authored by Anschel Schaffer-Cohen's avatar Anschel Schaffer-Cohen Committed by Russ Cox

exp/iterable: add UintArray

all other basic types seem to be represented.

R=rsc
CC=golang-dev
https://golang.org/cl/1919042
parent 8c5f30c0
......@@ -57,3 +57,16 @@ func (a StringArray) Iter() <-chan interface{} {
}()
return ch
}
type UintArray []uint
func (a UintArray) Iter() <-chan interface{} {
ch := make(chan interface{})
go func() {
for _, e := range a {
ch <- e
}
close(ch)
}()
return ch
}
......@@ -15,6 +15,10 @@ func TestArrayTypes(t *testing.T) {
if x := Data(bytes)[1].(byte); x != 2 {
t.Error("Data(bytes)[1].(byte) = %v, want 2", x)
}
uints := UintArray([]uint{1, 2, 3})
if x := Data(uints)[1].(uint); x != 2 {
t.Error("Data(uints)[1].(uint) = %v, want 2", x)
}
ints := IntArray([]int{1, 2, 3})
if x := Data(ints)[2].(int); x != 3 {
t.Error("Data(ints)[2].(int) = %v, want 3", x)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment