我在iex>中更新我的@doc以测试它的外观.我遇到的问题是我必须退出iex才能查看更新的@doc文档.有没有办法在使用r()时重新加载模块@doc变量?
iex -S mix
iex> h Coordinate.island/1
## Examples
iex> {:ok, coord } = Cordinate.start_link
Cordinate.island(coord)
:falls_town
Run Code Online (Sandbox Code Playgroud)
更新@doc以返回:none而不是:falls_town并保存文件.
iex> r(Coordinate)
iex> h Coordinate.island/1
# issue: still showing the old @doc example
## Examples
iex> {:ok, coord } = Cordinate.start_link
Cordinate.island(coord)
:falls_town # should be :none
Run Code Online (Sandbox Code Playgroud) 如何将管道占位符传递给函数中的第二个参数?
defdefmodule CamelCase do
str = "The_Stealth_Warrior"
def to_camel_case(str) do
str
|> Regex(~r/_/, 'need_to_pass_str_argument_here', "")
|> String.split(" ")
|> Enum.map(&(String.capitalize(&1)))
|> List.to_string
end
end
ExUnit.start
defmodule TestCamelCase do
use ExUnit.Case
import CamelCase, only: [to_camel_case: 1]
test "to_camel_case" do
assert to_camel_case("The_Stealth_Warrior") == "TheStealthWarrior"
end
end
# Error
iex>
** (FunctionClauseError) no function clause matching in Regex.replace/4
(elixir) lib/regex.ex:504: Regex.replace("The_Stealth_Warrior", ~r/\W/, " ", [])
Run Code Online (Sandbox Code Playgroud)