정수 배열을 바꾸는데 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?