제거됨: 심볼 리터럴

제거됨: 심볼 리터럴 (Symbol Literals)

심볼 리터럴(symbol literal)은 Scala 3에서 더 이상 지원되지 않아요. 대신 무엇을 써야 하는지, 그리고 예전 코드는 어떻게 바뀌는지 살펴볼게요.

출처: Scala 3 Reference

본문

심볼 리터럴은 더 이상 지원되지 않아요.

scala.Symbol 클래스는 여전히 존재하므로, 심볼 리터럴 'xyz를 문자 그대로 옮기면 Symbol("xyz")가 돼요. 하지만 일반 문자열 리터럴 "xyz"를 쓰는 걸 권장합니다. (Symbol 클래스는 미래에 deprecated되고 제거될 예정이에요.) 예시:

scalac Test.scala
-- Error: Test.scala:1:25 ------------------------------------------------------------------------------------------------

1 |@main def test = println('abc)
  |                         ^
  |                         symbol literal 'abc is no longer supported,
  |                         use a string literal "abc" or an application Symbol("abc") instead,
  |                         or enclose in braces '{abc} if you want a quoted expression.
  |                         For now, you can also `import language.deprecated.symbolLiterals` to accept
  |                         the idiom, but this possibility might no longer be available in the future.
1 error found

더 알아보기 (Learn more)