diff --git a/hash_map/hash_map.go b/hash_map/hash_map.go index 487020a..8a17aa3 100644 --- a/hash_map/hash_map.go +++ b/hash_map/hash_map.go @@ -49,8 +49,13 @@ func (this *HashMap) Conj(key any, val any) *HashMap { return Conj(this, key, val) } -func String(this *HashMap) string { - if this == nil { +func (this *HashMap) IsEmpty() bool { + return len(this._map) == 0 + +} + +func (this *HashMap) String() string { + if this.IsEmpty() { return "{}" } var sb strings.Builder @@ -63,8 +68,5 @@ func String(this *HashMap) string { sb.WriteRune(' ') } return sb.String()[:sb.Len()-2] + "}" -} -func (this *HashMap) String() string { - return String(this) }