2019-01-09 10:17:42 +03:00
|
|
|
package objects
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
// append(src, items...)
|
|
|
|
func builtinAppend(args ...Object) (Object, error) {
|
|
|
|
if len(args) < 2 {
|
2019-01-17 12:56:05 +03:00
|
|
|
return nil, ErrWrongNumArguments
|
2019-01-09 10:17:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
switch arg := args[0].(type) {
|
|
|
|
case *Array:
|
|
|
|
return &Array{Value: append(arg.Value, args[1:]...)}, nil
|
|
|
|
default:
|
|
|
|
return nil, fmt.Errorf("unsupported type for 'append' function: %s", arg.TypeName())
|
|
|
|
}
|
|
|
|
}
|