I'm learning the Elixir programming with elixir lang getting started , and I'm stacked of the record brace syntax
.
This is the sample:
defrecord FileInfo, atime: nil, accesses: 0
defmodule FileAccess do
def was_accessed?(FileInfo[accesses: 0]), do: false
def was_accessed?(FileInfo[]), do: true
end
While the author consider Elixir expands the record to a tuple at compilation time. so
def was_accessed?(FileInfo[accesses: 0]), do: false
is the same as:
def was_accessed?({ FileInfo, _, 0 }), do: false
But when I type in the Elixir shell:
iex(13)> FileInfo[access: 0] == {FileInfo, nil, 0}
true
iex(14)> FileInfo[access: 0] == {FileInfo, 0, 2}
false
The result turned out FileInfo[access: 0]
only equals to {FileInfo, nil, 0}
,
not { FileInfo, _, 0 }
.
What's the difference of these two scenes?