On Wed, 10 Dec 2003, David A. Black wrote:

> Hi --

Thanks for your comments.

> On Wed, 10 Dec 2003, Luke A. Kanies wrote:
>
> > 	# operations will be retrieved from the base class by name
> > 	# should i be using symbols here instead of strings?
>
> I don't think it matters, except that it might be a little faster with
> symbols if you're doing lots of hash access.  If you just want to give
> people the choice, you can canonicalize the object with #to_s or
> #intern.

Yeah, that's what I'll most likely do, I just wanted to verify that this
was a common practice before I set it all up.

> > 	def Operation.[](name)
> > 		unless @derivatives.include?(name)
> > 			raise "No class Operation::#{name}"
> > 		end
> >
> > 		return @derivatives[name]
> > 	end
>
> This is a place where you could, conceivably, use my favorite
> 1.8.0-and-greater "trick":
>
>   class Operation
>     @derivatives = Hash.new {|k,v| raise "No class Operation::#{v}" }
>     # ...
>     def Operation.[](name)
>       @derivatives[name]
>     end

Um, wow.  I'm awestruck, I think.

Thanks!  Ruby is very, very cool.

Luke

-- 
Due to circumstances beyond your control, you are master of your fate
and captain of your soul.