【发布时间】:2018-01-13 09:26:54
【问题描述】:
我想打印一个列表以及一个字符串标识符,例如
list = [1, 2, 3]
IO.puts "list is ", list
这不起作用。我尝试了一些变化,例如
# this prints only the list, not any strings
IO.inspect list
# using puts which also does not work
IO.puts "list is #{list}"
在 javascript 中,我可以简单地执行 console.log("list is ", list)。我很困惑如何在 elixir 中达到同样的效果。
【问题讨论】:
-
我最终为此创建了一个小型日志记录实用程序 - hexdocs.pm/slog/readme.html,因为我需要 JS 类型灵活的日志记录而不用担心类型。在我的开发设置中工作正常