LangWart: Method congestion from mutate multiplicty

Rick Johnson rantingrickjohnson at gmail.com
Sun Feb 10 13:55:35 EST 2013


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.



More information about the Python-list mailing list