AsDArray attempts to retrieve a *DArray from an Expr, returning a *DArray and a flag signifying whether the assertion was successful. The function should be used instead of direct type assertions wherever a *DArray wrapped by a *DOidWrapper is possible.
(e Expr)
| 1630 | // be used instead of direct type assertions wherever a *DArray wrapped by a |
| 1631 | // *DOidWrapper is possible. |
| 1632 | func AsDArray(e Expr) (*DArray, bool) { |
| 1633 | switch t := e.(type) { |
| 1634 | case *DArray: |
| 1635 | return t, true |
| 1636 | case *DOidWrapper: |
| 1637 | return AsDArray(t.Wrapped) |
| 1638 | } |
| 1639 | return nil, false |
| 1640 | } |
| 1641 | |
| 1642 | // MustBeDArray attempts to retrieve a *DArray from an Expr, panicking if the |
| 1643 | // assertion fails. |