i am trying to declare a dynamic array like below.
<% Product_in_Stock_array = [] %>
but it is not working giving syntax error.
You have to be a bit more specific.
The code you have is most likely an erb
template file. This is actually a valid erb
template
ERB.new('<% Product_in_Stock_array = [] %>').result
Your syntax error has to be somewhere else.
Additionally you most likely want to create a variable not a constant. In Ruby names starting with capital letter are constants (written in UpperCamelCase
or UPPER_CASE
most often), normal variables are written in camel_case
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.