From: Leslie Viljoen Date: 2005-08-12T21:44:59+09:00 Subject: Re: Array redefinition problem Reyn Vlietstra wrote: >heh, daars min afrikaaners op ruby-talk :) > > heh. van waaraf is jy? >Why dont you use one of the db wrappers, like dbi ? >Have you seen active_record ? > > Hm, maybe a good idea. Although I do actually want to solve this problem. Quite often with Ruby I get strange errors and end up spending a lot of time commenting large blocks of code out to try and narrow them dDoes anyone know of a program that can underown. My pet peeve is the "syntax error" on the last line of code - meaning I have missed an "end" somewhere. >On 8/12/05, Leslie Viljoen wrote: > > >>Hello! >> >>I have a large program which needs to be able to use Postgres OR MySQL. >>Since the MySQL module's query result has a num_rows method and Postgres >>returns an array, I thought I'd just redefine Array like this: >> >>class Array >> def num_rows >> return length >> end >>end >> >>But in another line (@entries = Array.new) I get: >> >>/var/www/ruby/core.rb:443:in `initialize': wrong number of arguments (0 >>for 2) (ArgumentError) >> >>Now if I do the same thing in a small test program, I get no errors. >>This works: >> >>class Array >> def num_rows >> return length >> end >>end >> >>res = Array.new >>puts res.num_rows >> >>In the large program I am not redefining Array anywhere else - what else >>can >>cause this error? >> >>Les >> >>-- >>ruby -e "puts 'Just another fickle programmer'" >> >>Leslie Viljoen [leslie@camary.co.za] >>Camary Consulting [http://www.camary.co.za] >>Cellphone [083-6186100] >>Personal web [http://mobeus.homelinux.org] >> >> >> >> >> >> > > > > -- ruby -e "puts 'Just another fickle programmer'" Leslie Viljoen [leslie@camary.co.za] Camary Consulting [http://www.camary.co.za] Cellphone [083-6186100] Personal web [http://mobeus.homelinux.org]