[#1816] Ruby 1.5.3 under Tru64 (Alpha)? — Clemens Hintze <clemens.hintze@...>

Hi all,

17 messages 2000/03/14

[#1989] English Ruby/Gtk Tutorial? — schneik@...

18 messages 2000/03/17

[#2241] setter() for local variables — ts <decoux@...>

18 messages 2000/03/29

[ruby-talk:01786] Is this a bug?

From: Clemens Hintze <clemens.hintze@...>
Date: 2000-03-09 10:47:32 UTC
List: ruby-talk #1786
(mailed & posted)

Hi,

I am using Ruby 1.4.3 yet! Now I have found a behavior that seems not
in-line with the documentation.

Please consider:

   /home/hintze/$ ruby
   $_ = "hello"
   p "1st: #$_"
   sub("e","a")
   p "2nd: #$_"
   ^D
   "1st: hello"
   "2nd: hallo"

It seems, that Kernel::sub also updates variable $_. From the
documentation I would assume, that it should only return a copy, and
shoud *not* update $_.

Updating $_ should be the task of Kernel::sub!.

Am I wrong?

\cle

PS: Same is for Kernel::gsub.

In This Thread

Prev Next