From: matz@... (Yukihiro Matsumoto) Date: 2001-08-14T13:40:03+09:00 Subject: [ruby-talk:19673] Re: Why not?: Assigning to self Hi, In message "[ruby-talk:19670] Re: Why not?: Assigning to self" on 01/08/14, Ryo Furue writes: |Now the "why" part of the question remains. I'm curious about why an |assignment to self is forbidden. Is it to avoid surprises? or is it |related to some technical problem? I could imagine that if it were |allowed, there could be lots of surprises; for example, | | class Array | def meth | s = "hello" | self = s | end | end | | a = [3.14, 2.9] | a.meth | puts a # prints "hello" !! | |But, what if an assignment to self is allowed only when both sides |refer to objets of the same class? This question is only out of |curiosity. Assignments in Ruby is changing reference. There's no copy in assignments. Your desired behavior (assignment to self) requires copying (something like Smalltalk's "become"), so that it cannot be assignment in Ruby. matz.