asi*_*niy 15 elixir
假设我有一个结构,struct = %MyApp.MyModel{ filled_with_data: "true }.
struct = %MyApp.MyModel{ filled_with_data: "true }
我如何获得结构名称(MyApp.MyModel在我的情况下)?
MyApp.MyModel
Dog*_*ert 25
它存储在一个名为场__struct__,所以struct.__struct__ == MyApp.MyModel.
__struct__
struct.__struct__ == MyApp.MyModel
phu*_*ehe 16
您还可以通过模式匹配获取结构名称:
%name{} = struct
归档时间:
9 年,3 月 前
查看次数:
3294 次
最近记录:
7 年,7 月 前