From: Tom C. <ta...@ca...> - 2005-07-15 12:14:09
|
Hello Dave On 15 Jul 2005, at 04:25, Dave Howell wrote: > Well, yes, but that was my point. I hadn't the faintest how to do > that. I find symbols still quite mysterious. I find it easiest to think of symbols as strings that never change. You can often use a string in place of a symbol (attr_accessor "title" works the same as attr_accessor :title) but symbols are one character less, and send a signal to anyone reading your code that the string is for internal use only (ie it won't be shown on the screen to the user). > Looking at your example, I see I'm going to have to go read up > on .class_eval, define_method, and instance_variable, all of which > I didn't even know I was looking for. :) But that sure looks like > exactly what I wanted to know. Thanks! You may also want to look at the Observer class that is built into ruby http://www.ruby-doc.org/stdlib/libdoc/observer/rdoc/index.html which reduces the code you need to type a bit. Tom |