【发布时间】:2013-05-17 07:17:49
【问题描述】:
我正在使用以下代码来满足我的需求:
(1 to 5)..map(i => s"\\x${i}") // Produces List("\\x1", "\\x2", "\\x3", "\\x4", "\\x5")
但我想使用占位符。根据the string interpolator documentation:
(1 to 5).map(s"\\x${_}")
应该扩展为:
(1 to 5).map(StringContext("\\\\x","").s(_))
但后者有效,前者无效,后者在_ 上抛出一个error: unbound placeholder parameter。为什么?
【问题讨论】:
标签: scala scala-2.10 string-interpolation