Re: Puzzled on the MatchData
by Volkan Civelek other posts by this author
Jun 30 2006 6:08PM messages near this date
Puzzled on the MatchData
|
[ANN] Mongrel 0.3.13.3 -- Ruby Licensed Release
Volkan Civelek wrote:
> Hi,
> I have a question...
>
> Why the below snippet,
>
> ["foo","bar","baz"].each do |s|
> m = /^ba(.*?)$/.match(s)
> puts m[0]
> end
>
> gives the following error?
>
> test.rb:8: undefined method `[]' for nil:NilClass (NoMethodError)
>
> Regards,
> Volkan
nevermind..
i understood now...
thanks
answer:
["foo","bar","baz"].each do |s|
m = /^ba(.*?)$/.match(s) and puts m[0]
end
--
Posted via http://www.ruby-forum.com/.
Thread:
Volkan Civelek
Volkan Civelek
|