Skip to content

프로젝트 3번 IOType 질문 #76

@Jahyeok-Koo

Description

@Jahyeok-Koo
enum IOType:
  case StdIO
  case DummyIO(var input: String, var output: String)

IOType 정의가 이렇게 되어있는데

given Reader[IOType] with
  extension (r: IOType)
    // Hint: Use scala.Console.in.read().toChar
    def readChar(): Option[Char] = r match {
      case StdIO => Some(scala.Console.in.read().toChar)
      case DummyIO(input, output) => {
        val char = input.headOption
        input = input.drop(1)
        char
      }
      case _ => None
    }

reader에서 DummyIO input에 접근하여 input을 수정하려 하니 val으로 선언되어 있어 안된다고 합니다.
IOType 정의상에는 var로 되어있는데 제가 잘못 짚고 있는것일까요?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions