[英]Elixir: Printing list along with string
我想打印一个列表以及字符串标识符
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 1.4开始, IO.inspect/2
接受label
选项等 :
IO.inspect list, label: "The list is"
#⇒ The list is: [1, 2, 3]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.