You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for int and float type,Why is binaryop compatible with both int and float fields, but not with equal function?
func (o *Int) Equals(x Object) bool {
t, ok := x.(*Int) //if x is float,then return false
if !ok {
return false
}
return o.Value == t.Value
}
func (o *Int) BinaryOp(op token.Token, rhs Object) (Object, error) {
switch rhs := rhs.(type) {
case *Int:
case *Float: //here compatible with both int and float
case *Char:
}
}
return nil, ErrInvalidOperator
}
The text was updated successfully, but these errors were encountered:
for int and float type,Why is binaryop compatible with both int and float fields, but not with equal function?
The text was updated successfully, but these errors were encountered: