[Markaby] Using cycle?

I can’t figure out how to get cycle to work:

tr :class=>@helpers.cycle(‘odd’, ‘even’) do
tr :class=>@helpers.cycle(‘odd’, ‘even’, :name=>‘rows’) do
[email protected](‘odd’, ‘even’) do

The first two output only one ‘class=“odd”’, the last causes an error.

Any help?

Thanks,
Joe

I can’t figure out how to get cycle to work:

tr :class=>@helpers.cycle(‘odd’, ‘even’) do
tr :class=>@helpers.cycle(‘odd’, ‘even’, :name=>‘rows’) do
[email protected](‘odd’, ‘even’) do

I believe cycle contains a closure that remembers what the last state
was
called with. So:
cycle(‘odd’,‘even’)
cycle(‘odd’,‘even’)

Would return
‘odd’
‘even’

You can try it out in the console. Each call “cycles”. So if you put it
into a loop, it will cycle through the options until the loop is exited.

[0,1,2].each{ |e| cycle(‘odd’,‘even’) }
odd
even
odd

Hope that helps.

-Steve

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs