Skip to content

Instantly share code, notes, and snippets.

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]
@Jentsch
Jentsch / Expressions in string interpolation.md
Last active August 21, 2022 01:26
Expressions in string interpolation

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.

Example:

scala> def f(x: Int) = x * 2