From: Jack Dempsey Date: 2001-12-16T06:53:52+09:00 Subject: [ruby-talk:28645] irb works, ruby doesn't... hi all, ok, this is bugging me...seems simple, but what's going on? i have these commands: m = Mysql.new('localhost', 'bot','PASS', db) tables = defined?(table) ? [table] : m.list_tables tables.each do |t| m.list_fields(t).fetch_fields.each do |f| puts f.name end end if i run it from ruby i get: [jack@Zeus ruby]$ ./dbf.rb test ./dbf.rb:41:in `list_fields': failed to convert nil into String (TypeError) from ./dbf.rb:41 from ./dbf.rb:40:in `each' from ./dbf.rb:40 [jack@Zeus ruby]$ but look at the irb session below...it seems fine! [jack@Zeus ruby]$ irb irb(main):001:0> require 'mysql' true irb(main):002:0> m = Mysql.new('localhost','bot','dbbot','test') # irb(main):003:0> tables = defined?(table) ? [table] : m.list_tables ["test", "test2"] irb(main):004:0> tables.each do |t| irb(main):005:1* m.list_fields(t).fetch_fields.each do |f| irb(main):006:2* print f.name, ' ' irb(main):007:2> end irb(main):008:1> end id c1 c2 c3 c4 c5 c6 c7 c8 c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 c20 c21 c22 c23 c24 c9 id c1 c2 c3 ["test", "test2"] irb(main):009:0> any ideas what's goin on? thanks! jack