[#807] Ruby 1.4.1 — Yukihiro Matsumoto <matz@...>
Ruby 1.4.1 is out, check out:
1 message
1999/09/16
[#808] Ruby 1.4.2 — Yukihiro Matsumoto <matz@...>
Ruby 1.4.2 is out, check out:
1 message
1999/09/16
[#816] My favorite language's icon turned into a sheep! — "Francois Le Coguiec" <francois_le_coguiec@...>
Weird!
6 messages
1999/09/27
[#826] feature request — Jonathan Aseltine <aseltine@...>
Hi,
8 messages
1999/09/29
[ruby-talk:00831] Re: feature request
From:
matz@... (Yukihiro Matsumoto)
Date:
1999-09-29 04:23:58 UTC
List:
ruby-talk #831
Hi,
In message "[ruby-talk:00830] Re: feature request"
on 99/09/29, OZAWA Sakuro <crouton@duelists.org> writes:
|What causes the difference below?
|The only difference is whether the assignment is done one-by-one or not.
Because the evaluated values of the blocks are different. For the
first case:
|x = 'a.b c.d'
|x.gsub!(/(\w)\.(\w)/) {
| i, j, k = $~
| print "#{i}, #{j}, #{k}\n"
| j, k = 'zzz', 'ZZZ'
|}
The evaluated value is the value of the multiple assignment,
which is the array ['zzz','ZZZ'].
On the other hand, for the second case:
|x = 'a.b c.d'
|x.gsub!(/(\w)\.(\w)/) {
| i, j, k = $~
| print "#{i}, #{j}, #{k}\n"
| j = 'zzz'
| k = 'ZZZ'
|}
The value is from the normal assignment, whose value is 'ZZZ'.
Since the gsub methods replaces the matches with the evaluated value
of the given block, the results are different.
Hope this helps
matz.