github.com/neugram/ng@v0.0.0-20180309130942-d472ff93d872/eval/testdata/typeswitch1.ng (about)

     1  ok := false
     2  
     3  v := interface{}(42)
     4  switch x := v.(type) {
     5  case int:
     6  	if x != 42 {
     7  		panic("ERROR-1")
     8  	}
     9  	ok = true
    10  case *int, []int:
    11  	panic("ERROR-2")
    12  case float64:
    13  	panic("ERROR-3")
    14  default:
    15  	panic("ERROR-4")
    16  }
    17  
    18  if !ok {
    19  	panic("ERROR")
    20  }
    21  
    22  print("OK")