[#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:01910] Re: Ruby Syntax similar to other languages?

From: matz@... (Yukihiro Matsumoto)
Date: 2000-03-16 17:04:29 UTC
List: ruby-talk #1910
Hi,

In message "[ruby-talk:01896] Ruby Syntax similar to other languages?"
    on 00/03/16, "David Douthitt" <DDouthitt@cuna.com> writes:

|as a veteran vi user (and sed user) it was nothing for me to adjust to
|
|     foo = s/this/that/g;
|
|but now with Ruby it seems this is
|
|     foo.gsub!(/this/, "that")
|
|what?  And if I don't want the "g" option, it's a completely different
|function:
|
|    foo.sub!(/this/, "that")
|
|and if I don't want the original to be modified:
|
|    foo.sub(/this/, "that")
|
|Can someone explain why all this is?  There must be a method to this madness....
|pun intended?

sub/gsub is from awk.  ! is inspired from scheme.

I suggest not to use String's bang methods too much, at least while
you are new to Ruby.  bang means a little bit more danger than non
bang.  You can forget it, if you meet confusion.
							matz.

In This Thread