On Sunday, February 10, 2013 3:53:57 AM UTC-6, Neil Hodgson wrote:
> Ruby does not use '!' to indicate in-place modification:

Really?

rb> a = [1,2,3]
[1, 2, 3]
rb> a.reverse
[3, 2, 1]
rb> a
[1, 2, 3]
rb> a.reverse!
[3, 2, 1]
rb> a
[3, 2, 1]

And now we will verify that a.reverse! has not assigned 'a' to a new object

rb> a = [1,2,3]
[1, 2, 3]
rb> aID = a.object_id
78906770
rb> a.reverse!
[3, 2, 1]
rb> a
[3, 2, 1]
rb> a.object_id
78906770

I'd love to hear an explanation for that.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to