Ruby Control Structures - Case (Bonus Question)

  • + 4 comments

    Why does this work?

    case obj
    
    when Hacker, Submission, TestCase, Contest 
    
        puts "It's a #{obj.class}!"
    else 
    
        puts"It's an unknown model"
    
    end
    

    When "k" == String it says false,

    "k" === String is also false

    what is the case logic in ruby?