Given this ERB code
<% @client.sessionables.ordered.by_program_completion.reverse_each do | program_name_and_completion, sessionables | %>
<% program_name, program_completion_date = program_name_and_completion %>
<% # Render stuff... %>
<% end %>
I would like to get rid of the second line, where I use the multiple variable assignment to extract program_name and program_completion_date from the program_name_and_completion array. One would assume it could be done directly in the block assignment, e.g.
sessionables.by_program_completion.each do | [program_name, program_completion_date], sessionables |
but the above snippet doesn't work, so my questions are:
- Is this at all possible with Ruby?
- If so, what's the correct syntax?