class A
def test
"Test from instance"
end
class << self
def test
"Test from class"
end
end
end
p A.send(:test) # "Test from class"
p A.new.method(:test).call # "Test from instance"
这里符号按预期工作,但在这里:
s="test"
s1=:s
p s1 # :s
为什么这里会打印 :s?我不理解背后的原因。请问有人能为我解释一下吗?