1
藥劑的文檔狀態在Elixir中使用drop_while?
drop_while(enumerable, fun)
Drops items at the beginning of the enumerable while fun returns a truthy value
但我很困惑與下面的輸出。這是否意味着一旦得到!truthy
一切都被視爲錯誤?
iex> Enum.drop_while([0,1,2,3,4,5], fn(x) -> rem(x,2) == 0 end)
[1,2,3,4,5]
我預期的[1,3,5]
因爲
iex> Enum.map([0,1,2,3,4,5], fn(x) -> rem(x,2) == 0 end)
[true,false,true,false,true,false]
我想了解它是如何工作的,而不是試圖得到我想要的輸出的輸出(有Enum.filter
實現)的結果
所以,'直到一個真值'是理解它的關鍵。 – Bala