[英]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.