3f55a6b5b0
Implement module imports
19 lines
381 B
Go
19 lines
381 B
Go
package objects
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
// append(src, items...)
|
|
func builtinAppend(args ...Object) (Object, error) {
|
|
if len(args) < 2 {
|
|
return nil, ErrWrongNumArguments
|
|
}
|
|
|
|
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())
|
|
}
|
|
}
|