我在考虑:
class X
def new()
@a = 1
end
def m( other )
@a == other.@a
end
end
x = X.new()
y = X.new()
x.m( y )
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
错误消息是:
syntax error, unexpected tIVAR
Run Code Online (Sandbox Code Playgroud)
我如何比较来自同一类的两个私有属性呢?