mirror of
https://github.com/teivah/100-go-mistakes.git
synced 2026-06-21 00:47:11 +08:00
Merge e95a45516d into c13d0b4807
This commit is contained in:
commit
f8af7fbf49
1 changed files with 1 additions and 1 deletions
|
|
@ -542,7 +542,7 @@ It’s essential to understand how to use `==` and `!=` to make comparisons effe
|
|||
|
||||
???+ note
|
||||
|
||||
We can also use the `?`, `>=`, `<`, and `>` operators with numeric types to compare values and with strings to compare their lexical order.
|
||||
We can also use the `<=`, `>=`, `<`, and `>` operators with numeric types to compare values and with strings to compare their lexical order.
|
||||
|
||||
If operands are not comparable (e.g., slices and maps), we have to use other options such as reflection. Reflection is a form of metaprogramming, and it refers to the ability of an application to introspect and modify its structure and behavior. For example, in Go, we can use `reflect.DeepEqual`. This function reports whether two elements are deeply equal by recursively traversing two values. The elements it accepts are basic types plus arrays, structs, slices, maps, pointers, interfaces, and functions. Yet, the main catch is the performance penalty.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue