Reputation: 3900
{:category => 1}.keys.each do |n|
case n
when 'category'
puts 'success'
else
puts "failure: #{n}"
end
end
This ends with "failure: category", and I cannot for the life of me see why, so I'm reasonably sure that I'm doing something enormously stupid.
Upvotes: 0
Views: 41
Reputation: 51191
You try to compare 'category'
string and :category
symbol - they are different:
'category' === :category
# => false
This should work:
{:category => 1}.keys.each do |n|
case n
when :category
puts 'success'
else
puts "failure: #{n}"
end
end
Upvotes: 2