Skip to content

Instantly share code, notes, and snippets.

@miguelsaddress
Last active February 15, 2016 08:37
Show Gist options
  • Save miguelsaddress/f688b70a23b3b1da782f to your computer and use it in GitHub Desktop.
Save miguelsaddress/f688b70a23b3b1da782f to your computer and use it in GitHub Desktop.
Code formatting for QHelper in Scala
// From: http://alvinalexander.com/scala/scala-class-object-function-convert-multiline-string-to-list-seq
implicit class QHelper( val sc : StringContext) {
def Q(args : Any*): Seq[String] = {
val strings = sc.parts.iterator
val expressions = args.iterator
var buf = new StringBuffer(strings.next)
while(strings.hasNext) {
buf append expressions.next
buf append strings.next
}
buf.toString.split("\n")
.toSeq
.map(_.trim)
.filter(_ != "")
}
}
// Now this one works for us:
val list = Q"""
http://angel.co/mile-high-organics
http://angel.co/kindara
http://angel.co/precog
http://angel.co/pivotdesk
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment