Added a IsList method for type checking []interface{}

This commit is contained in:
obscuren 2014-03-27 19:42:01 +01:00
parent 43cad69016
commit 7660e1ed90
1 changed files with 9 additions and 0 deletions

View File

@ -149,6 +149,15 @@ func (val *Value) IsStr() bool {
return val.Type() == reflect.String return val.Type() == reflect.String
} }
// Special list checking function. Something is considered
// a list if it's of type []interface{}. The list is usually
// used in conjunction with rlp decoded streams.
func (val *Value) IsList() bool {
_, ok := val.Val.([]interface{})
return ok
}
func (val *Value) IsEmpty() bool { func (val *Value) IsEmpty() bool {
return val.Val == nil || ((val.IsSlice() || val.IsStr()) && val.Len() == 0) return val.Val == nil || ((val.IsSlice() || val.IsStr()) && val.Len() == 0)
} }