Hi,
Although a newbie, I am really impressed of this powerful and consistent
language !
Accidently I used the << operator instead of the + operator to concatenate
two strings.
The result was a bit surprising (but intelligibly if one uses the wrong
method).
What bothers me is that Ruby does not issue a warning when a Const String is
modified by the << operator.
If I use the += operator I get a warning.
This seems to me a breach in terms of least surprise.
Do I overlook something ?
regards,
Joerg Leuzinger



def f(var1, var2)
  puts var1 << var2
end
CONST1 = 'Text1;'      # -> 'Text1;'
f(CONST1, 'Text2;')    # -> 'Text1;Text2;'
f(CONST1, 'Text3;')    # -> 'Text1;Text2;Text3;'
puts CONST1            # -> 'Text1;Text2;Text3;'



CONST2 = 'xy'          # -> "xy"
CONST2 << 'test'       # -> "xytest"
CONST2 += 'test'       # -> "xytesttest"
(irb):94: warning: already initialized constant CONST2

-- 
Werden Sie mit uns zum "OnlineStar 2002"! Jetzt GMX w?hlen -
und tolle Preise absahnen! http://www.onlinestar.de