From: Jack Dempsey Date: 2001-12-15T14:16:22+09:00 Subject: [ruby-talk:28599] rruby b Matz, Its here, finally :-) Its been hard to actually code this stuff because every two seconds I'm picking it up look up some syntax or method... I'm trying to familiarize myself with the ruby way, and although I could figure out a boring C style way of doing this, I'm wondering how I can do it with blocks... the basic idea is that this script will take a database and a table (if given) grab the types of the fields and populate it with random data...good for getting stuff setup quickly...when i get it done i'd be happy to send it to the list....so, onto the code.... So, what i'd like to do is this: m = Mysql.new(host, user, passwd, db) if defined? table m.list_fields(table).fetch_fields.each do |f| puts f.name end else m.list_tables.each do |table| m.list_fields(table).fetch_fields.each do |f| puts f.name end end end so, if table is defined, it uses that and grabs the fields for the table...else, it cycles through all the tables in the database...the m.list_fields block is the same in both situations though, so i know there must be a more elegant, more ruby like way to do this...any suggestions? thanks! jack