Hi all,
This is a summary of ruby-dev ML in these days.
[ruby-dev:19441] Integer#gcd
Masaki requested a new method Integer#gcd.
Shugo Maeda suggested alternative name, Math.gcd(m,n).
[ruby-dev:19449] new keyword once
See following simple search programs:
#1
ARGF.each do |line|
print line if line.index('PATTERN')
end
#2
ARGF.each do |line|
print line if line.index(/PATTERN/)
end
In most cases, Program #1 is SLOWER than #2. The reason is that
a string literal creates a new object for each iteration. So the
following program is faster than #1.
#3
pattern = 'PATTERN'
ARGF.each do |line|
print line if line.index(pattern)
end
K.Kosako proposed a new keyword `once' to resolve such kind of
problems. For example, following program creates a string object
only once (as of program #3).
ARGF.each do |line|
print line if line.index(once 'PATTERN')
end
Matz considers that the better plan is to make string literal create
an object only once.
-- Minero Aoki