Skip to content

Instantly share code, notes, and snippets.

Jentsch / Expressions in string
Last active May 11, 2016
Expressions in string interpolation
View Expressions in string

Expressions in string interpolation

During the fives episode of the [scalaprofies podcast][SP] the two Speaker where questioning for a special string interpolation that shows the definition of parts instead of evaluated result of the expressions. Invalid expressions should be still rejected by the compiler and refactoring tools should also affect the expressions within the string interpolation. Here we will implement such a functionality and see the tip of the of the iceberg of macros and string interpolation.


scala> def f(x: Int) = x * 2
View DependentKeyValue.scala
class Key[V] {
type Value = V
def ->(value: V) = Pair(this, value)
trait Pair {
val key: Key[_]
val value: key.Value
trait Map {
val pairs: Seq[Pair]