エントリーの編集
エントリーの編集は全ユーザーに共通の機能です。
必ずガイドラインを一読の上ご利用ください。
記事へのコメント2件
- 注目コメント
- 新着コメント
注目コメント算出アルゴリズムの一部にLINEヤフー株式会社の「建設的コメント順位付けモデルAPI」を使用しています
- バナー広告なし
- ミュート機能あり
- ダークモード搭載
関連記事
range over interface{} which stores a slice
Given the scenario where you have a function which accepts t interface{}. If it is determined tha... Given the scenario where you have a function which accepts t interface{}. If it is determined that the t is a slice, how do I range over that slice? func main() { data := []string{"one","two","three"} test(data) moredata := []int{1,2,3} test(data) } func test(t interface{}) { switch reflect.TypeOf(t).Kind() { case reflect.Slice: // how do I iterate here? for _,value := range t { fmt.Println(value)
2015/01/24 リンク