【发布时间】:2015-12-17 22:06:19
【问题描述】:
再次,如果这个问题对你来说很愚蠢,欢迎 scala 的新手和 downvote...
好的,我有一个名为“ListNode”的案例类,下面是我得到的错误:
scala> case class ListNode[Int](vl: Int, nt: ListNode[Int] = null) {
| def value: Int = vl
| def next: ListNode[Int] = nt
| }
defined class ListNode
scala> var a = ListNode(1)
a: ListNode[Int] = ListNode(1,null)
scala> var b = ListNode(2)
b: ListNode[Int] = ListNode(2,null)
scala> a.next = b
<console>:11: error: value next_= is not a member of ListNode[Int]
a.next = b
^
我读过this 和this 和this 和this 和this,但还是不太明白它的含义...
为什么我不能像在 Java 中一样,将下一个节点设置为另一个节点?
非常感谢。
【问题讨论】:
标签: scala