Robert Feldt <feldt / ce.chalmers.se> writes:

> IMHO the sentence
> 
> "..., returning nil if arr is unchanged."
> 
> does not fully describe the behavior
> 
> $ ruby -v -e 'puts [1,2,1].reverse!.inspect'
> ruby 1.6.1 (2000-10-05) [i386-cygwin]
> [1, 2, 1]

     a = "one"		# => "one"
     b = "two"		# => "two"
     c = "one"		# => "one"

     arr = [a, b, c]		# => ["one", "two", "one"]
     arr.collect {|i| i.id }	# => [537675204, 537674274, 537673344]
     arr.reverse!		# => ["one", "two", "one"]
     arr.collect {|i| i.id }	# => [537673344, 537674274, 537675204]

The array is changed, but with Fixnum's being singletons, the effect
is unnoticable. ;-)

Is this special case worth documenting?


Dave