Answers for "safe cast golang"

Go
0

safe cast golang

s, ok := v.(string)
if !ok {
    // the assertion failed.
}

// OR //

switch t := v.(type) {
case string:
    // t is a string
case int :
    // t is an int
default:
    // t is some other type that we didn't name.
}
Posted by: Guest on May-29-2020

Browse Popular Code Answers by Language