Fancy strings in Scala 3

PHOTO EMBED

Mon Apr 25 2022 20:16:17 GMT+0000 (Coordinated Universal Time)

Saved by @joel113 #scala

// compilation succeeds
val p1: LowerCased = LowerCased("Abc")

// compilation succeeds
LowerCased.from("abc")

// compilation fails:
// got a string which is not all lower case: Abc
LowerCased.from("Abc")

// compilation fails:
// got a value which is not a constant string: Usage.z
val z = "x" * 10
​​LowerCased.from(z)
content_copyCOPY

https://softwaremill.com/fancy-strings-in-scala-3/