【发布时间】:2018-03-16 03:49:15
【问题描述】:
我有一个看起来像这样的模块:
defmodule Othello.Game do
alias Othello.Game, as: Game
alias Othello.Utils, as: Utils
defstruct enabled_spaces: Utils.gen_list(Game.width() * Game.width(), fn _ -> false end),
is_game_over: false,
is_first_player: true
def width(), do: 8
end
是否可以从 defstruct 调用 width() 函数?
【问题讨论】:
-
旁注: 对
alias的调用可能会缩短为alias Othello.{Game,Utils}。
标签: elixir