I am trying to sift digits from a numeral string and count each occurrence of each different numeral. To my eyes, my syntax looks correct but I am constantly receiving a syntax error on my case statement; "unexpected 'when'". Can someone please tell me what I am doing wrong here?
prime_string = "23571113171923293137414347535961677173798389971011031071091131271311371391"
zeroes = 0
ones = 0
twos = 0
count_array = [zeroes, ones, twos]
def numsort(d)
case d
when 0
zeroes++
when 1
ones++
when 2
twos++
else
puts "err"
end
end
while prime_string.length > 0 do
numsort(prime_string.split.shift)
end
puts count_array