Exemplo n.º 1
0
/*
Range over the operands of the input array construct
and create new key value pair's using the NewPair()
method and add it to Pairs. Return.
*/
func NewPairs(array *expression.ArrayConstruct) (pairs Pairs, err error) {
	operands := array.Operands()
	pairs = make(Pairs, len(operands))
	for i, op := range operands {
		pairs[i], err = NewPair(op)
		if err != nil {
			return nil, err
		}
	}

	return
}
Exemplo n.º 2
0
func (this *JSConverter) VisitArrayConstruct(expr *expression.ArrayConstruct) (interface{}, error) {
	var buf bytes.Buffer
	buf.WriteString("[")

	for i, op := range expr.Operands() {
		if i > 0 {
			buf.WriteString(", ")
		}

		buf.WriteString(this.Visit(op))
	}

	buf.WriteString("]")
	return buf.String(), nil
}