score:0
a scala.xml.elem would be constructed which had the string contents represented as an arraybuffer, chopped up for every { } substitution. i'm certainly no authority but i believe what would happen is that there's a little extra overhead in construction the object and then getting the children and concatenating them together at runtime but, at least in this example, as soon as it's passed to the sql function which then extracts the string it wants (or perhaps this would be done with an implicit) the elem object would be discarded so there'd be a little extra memory usage, but only briefly.
but in the bigger picture, i don't think it's performance that would hinder the adoption of this solution but i guess a lot of people would be uncomfortable abusing xml in this way by using a made-up tag. the problem would be with other users reading the code later trying to figure out the semantic meaning of the tag... only to find there isn't one.
score:0
the example you give is almost certainly not doing string concatenation, it's creating parameterized sql statements (probably via jdbc's preparedstatement).
ironically, the lack of easy string concatenation is probably slightly encouraging best practices in this case (although i certainly wouldn't use that as an argument either way on the topic).
score:0
if you are coming to this question from the future, multi-line string interpolation is now a thing.
val when = "now"
println(s"""this is $when a thing.""")
// this is now a thing
Source: stackoverflow.com
Related Query
- Scala multiline string placeholder
- Is this a bug in Scala 2.10 String Interpolation inside a multiline String with backslash?
- Scala Converting multiline string to BigInt
- Scala multiline string extraction using regular expression
- Add json data to multiline string in scala to process using spark
- Idiomatic way to convert an InputStream to a String in Scala
- Remove Characters from the end of a String Scala
- How to insert double quotes into String with interpolation in scala
- What is the idiomatic scala way of finding, if a given string contains a given substring?
- Better String formatting in Scala
- How to check to see if a string is a decimal number in Scala
- What's the difference between raw string interpolation and triple quotes in scala
- How can I construct and parse a JSON string in Scala / Lift
- Scala - Get last two characters from string
- How to find if a Scala String is parseable as a Double or not?
- String interpolation in Scala 2.10 - How to interpolate a String variable?
- Convert list in Scala to a formatted string
- Is string concatenation in scala as costly as it is in Java?
- Generating a class from string and instantiating it in Scala 2.10
- scala String to scala.xml.Elem
- Scala String vs java.lang.String - type inference
- Hex String to Int,Short and Long in Scala
- akka HttpResponse read body as String scala
- Computing the MD5 hash of a string in scala
- Why are List and String identifiers named "xs" (in Scala and other languages)?
- Scala safe way of converting String to Enumeration value
- Scala - case match partial string
- Check if a string is blank or doesn't exist in Scala
- Getting object instance by string name in scala
- Generating a frequency map for a string in Scala
More Query from same tag
- Scala mongo driver custom codec for case classes
- Why does my plugin have the Scala version in its folder structure?
- How to map the Duration type to Interval?
- How do I change only one element of a Seq?
- Spark dataframe to nested map
- akka-http HttpEntity.toStrict timed out while still waiting for outstanding data
- End-dating records using window functions in Spark SQL
- accept multiple types for a parameter in scala
- Type mismatch on abstract type used in pattern matching
- Scala - semicolon inconsistency
- Most Stable Version of Drools
- Run a single test suite from build.sbt
- scala how to reduce while n > 0
- Using Option with .map() and .getOrElse()
- Akka HTTP + actor + slick postgresql
- Subqueries, Having and GroupBy in Slick
- In graphX, how to partition a graph with a custom PartitionStrategy that makes use of its topology?
- Apache Spark RDD Split "|"
- Parameterized method with Ordering?
- Validating list of strings
- How do I write a scala extractor for a case class with default parameters?
- CORS issue(403) in Ionic using Scala
- how to collect data after window operation? GroupBy messes up the order and I get incorrect results
- Titan DB - Hbase Compatibility Issue
- Cats instances for Some and None et al
- How to combine F-bounded polymorphism with associated types in Scala?
- How to compare elements of an array in scala (using tail recursive)
- Slick does not know how to map the given types - Option(DateTime.now)
- Block can not contain declarations
- Ordering while Splitting and Appending the same column vertically in Spark