On Wed, Oct 1, 2008 at 12:09 PM, Seth Thomas Rasmussen <[EMAIL PROTECTED]> wrote: > Aha. So, after fully reading the Rules, I developed a theory that the > example shown there is all wrong because inside the app() block, self > is changed to your app, which has no @stack instance. Running your > sample code, that seems confirmed with the error "undefined method > 'append' for nil:NilClass" shown in the console. > > This works: > > class Messenger > def initialize(stack) > @stack = stack > end > > def add(msg) > @stack.app do > @messages.append do > para msg > end > end > end > end > > Shoes.app do > @messages = stack > @messenger = Messenger.new @messages > > button "go" do > @messenger.add "dy-no-mite" > end > end
I should not say that the current Messenger example on the Rules page is "all wrong", but it is maybe a little misleading. If you took my example from this thread, and had the stack passed to Messenger.new named @stack as well, then it should work. I would recommend the manual be updated to include an associated sample app with the Messenger class similar to the example I gave here, though. I think using @stack in both spots is part of what is misleading about the current example. Also, meaningful variable names are always nice. :) -- Seth Thomas Rasmussen http://greatseth.com
