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

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