None
用於表示Python中缺少值。Scala中無等價物
例如,對於鏈表的節點類:
class Node:
def __init__(self, data=None, next_node=None):
self.data = data
self.next_node = next_node
有沒有辦法在Scala中做到這一點?我試過null
,但有些消息來源建議不要使用它。
class Node(new_data: Integer = null, new_next_node: Node = null) {
var data = new_data
var next_node = new_next_node