19 lines
355 B
Go
19 lines
355 B
Go
package object
|
|
|
|
func NewEnvironment() *Environment {
|
|
return &Environment{store: map[string]Object{}}
|
|
}
|
|
|
|
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, obj Object) Object {
|
|
e.store[name] = obj
|
|
return obj
|
|
}
|