q.As and q.AsE¶
Type assertion with a bubble on failure — the comma-ok pattern specialised to v, ok := x.(T).
Signatures¶
func As[T any](x any) T
func AsE[T any](x any) OkResult[T]
var ErrBadTypeAssert = errors.New("q: type assertion failed")
The type parameter T must be supplied explicitly — Go can't infer it from the single any argument. Both bare and chain forms use q.As[T](x) / q.AsE[T](x).
What q.As does¶
rewrites to:
Chain methods on q.AsE[T]¶
Same as q.OkE. Useful example:
Statement forms¶
Same five positions as q.Try.