我有一個類問題定義equals()方法操作
open class Texture
,我想定義equals(other: Texture)
操作
operator fun equals(other: Texture) = ...
,但我得到
Error:(129, 5) Kotlin: 'operator' modifier is inapplicable on this function: must override ''equals()'' in Any
什麼這是什麼意思?
如果我改變,要
operator fun equals(other: Any) = ...
Accidental override, two declarations have the same jvm signature
更新了答案,由於問題的更新。 – hotkey
當'other'不是'Texture'的實例時,如何安排函數返回'false'? – saulspatz