gpt4 book ai didi

scala - 带有替代方法的重载方法值

转载 作者:行者123 更新时间:2023-12-04 02:09:51 26 4
gpt4 key购买 nike

我有以下几点:

def calc(dir: File): Option[Group] = {
calcModel(dir) match {
case Some(model: Model) => calcUI(model, centerpane.getWidth, centerpane.getHeight, 5, MAX_LEVEL)
case None => None
}
}

def calcUI(model: Model, availableWidth: Double, availableHeight: Double, maxLevel: Int): Option[Group] = {
}

def calcUI(model: Model, posX: Double, posY: Double, availableWidth: Double, availableHeight: Double, horizontally: Boolean, startLevel: Int, maxLevel: Int): Option[Group] = {
}

protected def calcUI(node: Node, posX: Double, posY: Double, availableWidth: Double, availableHeight: Double, horizontally: Boolean, level: Int, maxLevel: Int): Group = {
}

def calcModel(dir: File): Option[Model] = {
}

(备注:模型不是从节点派生的)

并获得以下编译器错误消息:
Error:(88, 27) overloaded method value calcUI with alternatives:
(node: org.rob.spaceview.modell.Node,posX: Double,posY: Double,availableWidth: Double,availableHeight: Double,horizontally: Boolean,level: Int,maxLevel: Int)javafx.scene.Group <and>
(model: org.rob.spaceview.modell.Model,posX: Double,posY: Double,availableWidth: Double,availableHeight: Double,horizontally: Boolean,startLevel: Int,maxLevel: Int)Option[javafx.scene.Group] <and>
(model: org.rob.spaceview.modell.Model,availableWidth: Double,availableHeight: Double,maxLevel: Int)Option[javafx.scene.Group]
cannot be applied to (org.rob.spaceview.modell.Model, Double, Double, Int, Int)
case Some(model) => calcUI(model, centerpane.getWidth, centerpane.getHeight, 5, MAX_LEVEL)
^

我不明白。所有 calcUI 函数都因参数而异。

我知道这个错误,大部分时间我都会得到它并修复它。但在这里,没有线索。

希望有人启发我。谢谢。

最佳答案

实际上,调用中的给定参数

case Some(model) => calcUI(model, centerpane.getWidth, centerpane.getHeight, 5, MAX_LEVEL)

不对应于任何定义的 calcUI方法。例如对于以下定义
def calcUI(model: Model, availableWidth: Double, availableHeight: Double, maxLevel: Int): Option[Group]

你有一个比需要的更多的论据。

关于scala - 带有替代方法的重载方法值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22399593/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com