ruby - Is iterating over a constant a best practice or not? -


in ruby script, i'm declaring constant outside of method:

syndications = %w(advanced syndication, boxee feed, player mrss, ipad mrss, iphone mrss, youtube) 

and iterating in method like:

def some_method    syndications.each |syndication|       puts syndication    end end 

is iterating on constant idea or not?

you aren't iterating on constant — iterating on array, happens referenced constant. constant kind of variable isn't meant reassigned. don't deal constant — deal object references.

so question becomes: ok iterate on array?

and obvious answer question is: yes.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -