Ruby: interpolated string to variable name

Viewed 2111

In Ruby, how can I interpolate a string to make a variable name?

I want to be able to set a variable like so:

"post_#{id}" = true

This returns a syntax error, funnily enough:

syntax error, unexpected '=', expecting keyword_end
2 Answers
Related