I have the following method:
def speciate
chem_formula.each { |chemical|
@chem_species = chemical.scan(/[A-Z][^A-Z]*/)
puts @chem_species
}
end
that produces:
H2
S
O4
@chem_species = ["S", "O4"]
from: @chem_formula = ["H2" "SO4"]
How do you set the array to include all iterations? That is how do you output ["H2", "S", "O4"]
rather than ["S", "O4"]
Thank you in advance.