My code is as follows:
class HuffmanNode(val chars: String, val occurrences: Int) {
override def toString: String = "{" + chars + "|" + occurrences + "}"
def absoluteValue: Int = occurrences
def getChars: String = chars
def getOccurrences: String = occurrences.toString
}
object HuffmanNode {
def apply(chars: String, occurrences: Int): HuffmanNode = {
new HuffmanNode(chars, occurrences)
}
}
I'm trying to create a list of HuffmanNode, e.g.:
val PQ: List[HuffmanNode] = List(HuffmanNode("a", 3), HuffmanNode("b", 3))
How do I access the methods inside the HuffmanNode?
I tried doing this:
PQ(0).getChars
But I get an error saying, unable to resolve symbol getChars.
What could the problem be?