Skip to content

Commit

Permalink
Make == operator behave like == from spec
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoholiveira committed Dec 9, 2024
1 parent 2cc20c2 commit 800dac4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion comp.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func equals(a, b interface{}) bool {
}

if isNumber(a) {
return toNumber(a) == toNumber(b)
return isPrimitive(b) && toNumber(a) == toNumber(b)
}

if isBool(a) {
Expand All @@ -85,5 +85,9 @@ func equals(a, b interface{}) bool {
return isTrue(a) == isTrue(b)
}

if !isString(a) || !isString(b) {
return false
}

return toString(a) == toString(b)
}

0 comments on commit 800dac4

Please sign in to comment.