Now there are a lot of similar questions but no one where the warning occurs in a "case when expression"
I get the warning: already initialized constant for each of my "cases" in a "switch"-statement (I know that they are called different in ruby "switch" = "case" | "case" = "when", but i think you get the idea)
My Code:
Type = case entity.class.to_s
when 'A' then 1
when 'B' then 10
when 'C' then 2
when 'D' then 7
else raise "Unknown Type"
end
How do i get rid of the warning, because i just initialize it at the top, or am i missing something?
Edited: My Code is inside a loop. Like this:
loopcounter = 0
EntityType = 'test'
while loopcounter < 4
EntityType = case 'StDm'
when 'StDm' then 1
when 'Drt' then 10
when 'Pst' then 2
when 'StSnet' then 7
else raise "Unknown EntityType"
end
loopcounter += 1
end
puts EntityType