21 lines
367 B
Go
21 lines
367 B
Go
package object
|
|
|
|
func NewEnvironment() *Environment {
|
|
s := make(map[string]Object)
|
|
return &Environment{store: s}
|
|
}
|
|
|
|
type Environment struct {
|
|
store map[string]Object
|
|
}
|
|
|
|
func (e *Environment) Get(name string) (Object, bool) {
|
|
obj, ok := e.store[name]
|
|
return obj, ok
|
|
}
|
|
|
|
func (e *Environment) Set(name string, val Object) Object {
|
|
e.store[name] = val
|
|
return val
|
|
}
|