Why is this case when not working properly?

后端 未结 2 1607
隐瞒了意图╮
隐瞒了意图╮ 2021-01-23 08:31
  if ( item::class == RPG::Weapon )
    print \"yup\"
  end
  case item::class
  when RPG::Item
    type = 0
  when RPG::Weapon
    type = 1
  when RPG::Armor
    type =         


        
2条回答
  •  误落风尘
    2021-01-23 09:11

    Just case item will be sufficient - no need for case item::class.

    Case matching in Ruby is done with a fuzzy matching (===) algorithm that doesn't need such specific clauses.

提交回复
热议问题