我修改一个整数数组时,在 ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin13] 下得到了意外的结果。
values = [
2, 134, 163, 215, 108
]
=> [2, 134, 163, 215, 108]
target = 108
=> 108
values.delete(target)
=> 108
稍微改变写法,结果还是一样。
是我写错了,还是别的命令覆盖了这个操作,甚至是有什么东西损坏了?我不确定,该怎么检查呢?
从英语翻译·查看原文Changing an integer array gives me a surprising result under ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin13] :
values = [
2, 134, 163, 215, 108
]
=> [2, 134, 163, 215, 108]
target = 108
=> 108
values.delete(target)
=> 108
small changes to how i write it keep producing that result.
am i writing this incorrectly, is another command overriding what this does or, even worse, could something be corrupted? how can i check, becuase i'm unsure?