It seems that the delete method of array class uses different conventions comparing with other methods. The '!' usually used after a method in ruby means that the method will change the status of the object. However, 'delete' of array is against that rule. I encountered the problem today, and spent some time on debugging. Pretty annoying. Also, copy is copying reference by default, not by value comparing with c++.
the next example shows it more clearly:
irb> a = [1,2,3]
=> [1,2,3]
irb> a.delete 1
=> [2,3]
irb> a
=> [2,3]
No comments:
Post a Comment