OCaml boolean expression [[]] == [[]]
boolean, expression, list, ocaml
Solution
Use `=` since you have structural equality for comparing two values:
# [[]] = [[]];;
- : bool = true
Because `==` is reference equality, it only returns true if you refer to the same memory location:
let a = [[]]
let b = a
# b == a;;
- : bool = true
Problem
I have a function that return `[[]]`, and I want to test the result as unit test. But I found that the expression `[[]] == [[]]` return `false`. Here a simple test code: ``` # [[]] == [[]];; - : bool = false ``` Can someone explain me why this expression is evaluated as false? Thanks.