This commit is contained in:
parent
3076897eb7
commit
e869e6c9bd
27
ucl/objs.go
27
ucl/objs.go
|
@ -98,6 +98,33 @@ func (ss StringListObject) Index(i int) Object {
|
||||||
return StringObject(ss[i])
|
return StringObject(ss[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type HashObject map[string]Object
|
||||||
|
|
||||||
|
func (ho HashObject) String() string {
|
||||||
|
return fmt.Sprintf("%v", ho)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ho HashObject) Truthy() bool {
|
||||||
|
return len(ho) > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ho HashObject) Len() int {
|
||||||
|
return len(ho)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ho HashObject) Value(k string) Object {
|
||||||
|
return ho[k]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ho HashObject) Each(fn func(k string, v Object) error) error {
|
||||||
|
for k, v := range ho {
|
||||||
|
if err := fn(k, v); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
type iteratorObject struct {
|
type iteratorObject struct {
|
||||||
Iterable
|
Iterable
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue