Created
December 6, 2010 19:28
-
-
Save hamnis/730779 to your computer and use it in GitHub Desktop.
Message in an IRC client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Compilation completed with 2 errors and 0 warnings | |
error: overriding value arguments in class Message of type List[String]; | |
value arguments needs `override' modifier | |
case class Ping(arguments: List[String]) extends Message(None, PING, arguments) | |
error: overriding value arguments in class Message of type List[String]; | |
value arguments needs `override' modifier | |
case class Pong(arguments: List[String]) extends Message(None, PONG, arguments) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Message(origin: Option[Origin], command: NameAndFormat, arguments: List[String]) { | |
def format = { | |
val builder = new StringBuilder() | |
origin.foreach(x => builder.append(":").append(x.name).append(" ")) | |
command match { | |
case Status(c, n) => builder.append(c) | |
case Command(n) => builder.append(n) | |
} | |
builder.append(" ") | |
builder.append(arguments.mkString(" ")) | |
builder.append("\r\n") | |
builder.toString | |
} | |
} | |
case class Ping(arguments: List[String]) extends Message(None, PING, arguments) | |
case class Pong(arguments: List[String]) extends Message(None, PONG, arguments) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment