Created
October 14, 2016 18:13
-
-
Save pfeilbr/2308aa6e5a90344d1c383712de8c9f8c to your computer and use it in GitHub Desktop.
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" | |
"testing" | |
) | |
func TestSliceTypeAssertion(t *testing.T) { | |
fn := func(v interface{}) { | |
switch typ := v.(type) { | |
default: | |
fmt.Printf("typ: %v\n", typ) // output: typ: [milk eggs cheese] | |
} | |
} | |
items := []string{"milk", "eggs", "cheese"} | |
fn(items) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment