E008: 멤버가 아님

E008: 멤버가 아님 (Not A Member)

이 에러는 주어진 타입에 존재하지 않는 멤버(메서드, 필드, 타입)에 접근하려 할 때 발생해요. 흔히 이런 경우에 일어나요.

출처: Scala 3 Reference

본문

Example

val result = "hello".unknownMethod

Error

-- [E008] Not Found Error: example.scala:1:21 ----------------------------------
1 |val result = "hello".unknownMethod
  |             ^^^^^^^^^^^^^^^^^^^^^
  |             value unknownMethod is not a member of String

Solution

// Use a method that exists on the type
val result = "hello".toUpperCase
// Check the spelling and use the correct method name
val result = "hello".length
// Import extension methods if needed
extension (s: String)
  def unknownMethod: String = s.reverse

val result = "hello".unknownMethod

더 알아보기

  • 확장 메서드(extension method)에 대한 내용은 "Contextual Abstractions - Extension Methods" 섹션을 참고하세요.