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

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