2014-01-11 78 views
0

例如換行:如何逃避宏觀quasiquotes

q"import scala.collection.mutable.Buffer\ndef foo: Buffer[Int] = ???" 

這給出了一個錯誤,因爲換行符沒有得到解決。

+1

三重引號,真的打破了界限? – pedrofurla

回答

2

樣品從我的TMP目錄:

evals += q"""assert ($x.productArity >= ${args.length - 1}, 
    "Bad product arity ("+ $x.productArity +") for assignment")""" 

或者,只用一個半:

q"import scala.collection.mutable.Buffer; def foo: Buffer[Int] = ???" 

不能拼接的東西被解析掉。