refactor objects
This commit is contained in:
@@ -32,10 +32,24 @@ func (b Boolean) Inspect() string {
|
||||
return fmt.Sprintf("%t", b.Value)
|
||||
}
|
||||
|
||||
func (b Boolean) Clone() Object {
|
||||
// Copy implements the Copyable interface
|
||||
func (b Boolean) Copy() Object {
|
||||
return Boolean{Value: b.Value}
|
||||
}
|
||||
|
||||
// Hash implements the Hasher interface
|
||||
func (b Boolean) Hash() HashKey {
|
||||
var value uint64
|
||||
|
||||
if b.Value {
|
||||
value = 1
|
||||
} else {
|
||||
value = 0
|
||||
}
|
||||
|
||||
return HashKey{Type: b.Type(), Value: value}
|
||||
}
|
||||
|
||||
func (b Boolean) String() string {
|
||||
return b.Inspect()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user