Last active
February 15, 2016 08:37
-
-
Save miguelsaddress/f688b70a23b3b1da782f to your computer and use it in GitHub Desktop.
Code formatting for QHelper in Scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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