[lectures/02-interfaces] Update type switch slide.

This commit is contained in:
Arseny Balobanov 2021-02-25 15:34:54 +03:00
parent e09f4dc6b8
commit 72f428d81c

View file

@ -376,20 +376,20 @@ Check type
* Type switch * Type switch
func sqlQuote(x interface{}) string { func sqlQuote(x interface{}) string {
switch x := x.(type) { switch v := x.(type) {
case nil: case nil:
return "NULL" return "NULL"
case int, uint: case int, uint:
return fmt.Sprintf("%d", x) // x has type interface{} here. return fmt.Sprintf("%d", v) // v has type interface{} here.
case bool: case bool:
if x { if v {
return "TRUE" return "TRUE"
} }
return "FALSE" return "FALSE"
case string: case string:
return sqlQuoteString(x) // (not shown) return sqlQuoteString(v) // (not shown)
default: default:
panic(fmt.Sprintf("unexpected type %T: %v", x, x)) panic(fmt.Sprintf("unexpected type %T: %v", v, v))
} }
} }