我有一个十六进制网格的整数坐标结构,我将其从 C# 移植到 Scala,如下所示:
object Cood
{
def Up = new Cood(0, 2)
def UpRight = new Cood(1, 1)
def DownRight = new Cood(1,- 1)
def Down = new Cood(0, - 2)
def DownLeft = new Cood(- 1, - 1)
def UpLeft = new Cood(- 1, + 1)
def None = new Cood(0, 0)
}
class Cood(val x: Int, val y: Int)
{
//more code
}
由于非基本类型没有常量,因此它们是静态获取属性。在 Scala 中,我应该将它们实现为 def 或 val 还是无关紧要?