Doing this works fine:
q = case period_group
when 'day' then [7, 'D']
when 'week' then [7, 'WW']
else ['12','MM']
end
limit,pattern = q[0],q[1]
But my first try:
limit, pattern = case period_group
when 'day' then 7, 'D'
when 'week' then 7, 'WW'
else '12','MM'
end
ends up in a SyntaxError:
syntax error, unexpected ',', expecting keyword_end
when 'day' then 7, 'D'
Am I missing something?
You should be returning array for this. Otherwise it confuses the parser.
limit, pattern = case period_group
when 'day' then [7, 'D']
when 'week' then [7, 'WW']
else ['12','MM']
end
I don't see why you wanted to get rid of square brackets. It's even more readable that way.
you forgot to put returned values inside []
limit, pattern = case period_group
when 'day' then [7, 'D']
when 'week' then [7, 'WW']
else ['12','MM']
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With