[#4567] Re: What's the biggest Ruby development? — Aleksi Niemel<aleksi.niemela@...>

Dave said:

18 messages 2000/08/23
[#4568] Q's on Marshal — Robert Feldt <feldt@...> 2000/08/23

[#4580] RubyUnit testcase run for different init params? — Robert Feldt <feldt@...> 2000/08/25

[#4584] Re: RubyUnit testcase run for different init params? — Dave Thomas <Dave@...> 2000/08/25

Robert Feldt <feldt@ce.chalmers.se> writes:

[#4623] Re: RubyUnit testcase run for different init params? — Robert Feldt <feldt@...> 2000/08/28

On Sat, 26 Aug 2000, Dave Thomas wrote:

[#4652] Andy and Dave's European Tour 2000 — Dave Thomas <Dave@...>

24 messages 2000/08/30
[#4653] Re: Andy and Dave's European Tour 2000 — matz@... (Yukihiro Matsumoto) 2000/08/30

Hi,

[#4657] Ruby tutorials for newbie — Kevin Liang <kevin@...> 2000/08/30

Hi,

[ruby-talk:4607] Re: Getting list of regexp matches

From: ts <decoux@...>
Date: 2000-08-27 15:39:22 UTC
List: ruby-talk #4607
>>>>> "S" == Stephen White <steve@deaf.org> writes:

S> I'm guessing the reason is because '<<' is implemented by a local method,
S> whereas "+=" is implemented by another class so that means a couple more
S> bounces around the class hierachy to resolve what to call? Is that right?

pigeon% cat b.rb
#!/usr/bin/ruby
a = File.new("a").read(nil)
table = {}
pattern = /(new|table|end)/
a.scan(pattern) {|i|
   table[i] ||= []   
   table[i] += $~.begin(0)
}
puts table.inspect
pigeon% 

pigeon% b.rb
{["new"]=>[6, 20], ["table"]=>[0], ["end"]=>[10]}
pigeon% 

pigeon% /usr/bin/ruby -v
ruby 1.4.6 (2000-08-16) [i686-linux]
pigeon% 

pigeon% ./ruby b.rb
b.rb:7:in `+': wrong argument type Fixnum (expected Array) (TypeError)
        from b.rb:7
        from b.rb:5:in `scan'
        from b.rb:5
pigeon% 

pigeon% ./ruby -v
ruby 1.6.0 (2000-08-24) [i686-linux]
pigeon% 

 It work with 1.4.6 and 1.6.0 with <<


Guy Decoux

In This Thread

Prev Next