From: "David A. Black" Date: 2004-09-24T09:40:38+09:00 Subject: Re: mixin with A::B syntax Hi -- On Fri, 24 Sep 2004, Brian Schroeder wrote: > On Thu, 23 Sep 2004 19:52:01 +0000, eagle eyes joe wrote: > > > Greetings, > > > > I want to define a generic print method to use in debugging. I got the > > mix in syntax okay for classes like Hash or String, but for Mysql::Result, > > it doesn't seem to work. What would the proper syntax be? > > > > > > Joe Alotta > > > > > > #!/usr/bin/ruby > > > > require 'mysql' > > > > class Mysql::Result > > def print > > self.each_hash do |i| > > i.each do |k, v| { print "#{k} = #{v} "} puts > > > > end > > end > > end > > > > m = Mysql.new("localhost", "root", "", "Development") > > > > s = m.query("select * from symbols where type = 'MU'") > > > > s.print > > > > > > Joe Alotta > > module Mysql > class Result > def print > [...] > end > end > end I believe that should have the same effect as Joe's example. The only difference between going one at a time and doing Mysql::Result is the scope of constants. David -- David A. Black dblack@wobblini.net