Forums | Admin

Discussion Forums: help

Start New Thread Start New Thread

 

By: Brian Wisti
RE: "@iterators not initialized" warning [ reply ]  
2006-06-20 23:22
I've made a similar change (using if/else instead of the ternary operator) and committed to CVS. The warning should go away with 2.2.3

By: Brian Wisti
RE: "@iterators not initialized" warning [ reply ]  
2006-06-20 23:01
Hey, that's not good. When did I stop running with -w? Silly me. Looks like it's time for a 2.2.3!

By: Paul DuBois
"@iterators not initialized" warning [ reply ]  
2006-06-18 04:20
When I run ruby with the -w (which is my habit) and a template includes an [%in%] directive that does not include a :name option, I get this warning:

/usr/local/lib/ruby/site_ruby/1.8/PageTemplate/commands.rb:453: warning: instance variable @iterators not initialized

The code in question in commands.rb is:

# Print the output of all the objects joined together.
case
when @iterators.nil? || @iterators.empty?

When I look at initialize, it seems as though @iterators is initialized only sometimes:

def initialize(called_as, value, iterators)
@called_as = called_as
@value = value
@iterators = iterators.strip.gsub(/\s+/,' ').split if iterators
@switched = false
@commands = BlockCommand.new
@elseCommands = BlockCommand.new
@in_else = false
end

Perhaps the @iterators intialization should be something like this?

@iterators = iterators ? iterators.strip.gsub(/\s+/,' ').split : nil

I don't know if that change is correct, but it makes the warning go away, and my scripts still seem to work.