gpt4 book ai didi

python - 相当于 Ruby "is"

转载 作者:太空狗 更新时间:2023-10-29 21:25:19 26 4
gpt4 key购买 nike

Python 的“is”是否有 Ruby 等价物?它测试两个对象是否相同(即具有相同的内存位置)。

最佳答案

使用 a.equal? b

http://www.ruby-doc.org/core/classes/Object.html

Unlike ==, the equal? method should never be overridden by subclasses: it is used to determine object identity (that is, a.equal?(b) iff a is the same object as b).

关于python - 相当于 Ruby "is",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35634/

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