假设我有以下内容:
defmodule Operator do
defstruct operator: nil
@type t :: %Operator {
operator: oper
}
@type oper :: logic | arithmetic | nil
@type logic :: :or | :and
@type arithmetic :: :add | :mul
end
那么我可以:
o = %Operator{operator: :and}
是否可以检查 o.operator
是 逻辑运算符
,算术运算符
还是nil
?