私はis_function
で、いくつかの組み込み関数をテストしたいが、それは失敗します。エリクサー:is_function
> add = fn a, b -> a + b end
#Function<12.118419387/2 in :erl_eval.expr/5>
> is_function add
true
> is_function is_function # test itself
warning: variable "is_function" does not exist and is being expanded to "is_function()", please use parentheses to remove the ambiguity or change the variable name
iex:27
組み込み関数をテストするためにどのように?
もう1つのしわについて考えてみましょう。元のポスターの例では、addは_variable_です。これにはラムダが含まれています。 is_functionは名前付き関数です。私は、is_function(&is_function/1)は動作しますが、is_function(&add/0)は動作しません。どちらもis_function(&add/2)はしません。完璧さのために。 –
これはfalseを返すことはありません。 'A'モジュールが存在しないにもかかわらず' is_function(&A.b/1)#=> 'となります。 – Dogbert
ローカル関数の場合、関数が存在しない場合、これはコンパイル時エラーになります。 – Dogbert