You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider the following example:
You have a function that accepts an argument list of type `interface{}`
fmt(format string, args...interface{})
If you want to find out the type of an arg, we just loop over `args` and process each
`arg` in a type switch.
swtich t := arg.(type) {
case int:
// handle int
case int8:
// handle int8 etc...
}
In most cases you just want to know if a value is of a certain type class like `u/int`
to `u/int64`.
In that case you have to explicitly write a `case` statement for every type.
I don't know if that was explicitly avoided when defining the Go spec, but here is a
proposal for type ranges
switch t := arg.(type) {
case intish:
// t is cast to an int64 here
case floatish:
// t is cast to a float64 here
...
}
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: