Top > Ruby [2.2.2] > Hash( key? , value? )


Hash# key? , value?

hash = {:acha=>1, :porute=>2, :piipo=>30}

p hash.key? :acha              # true
p hash.key? :porute            # true
p hash.key? :pipo              # false

p hash.value? 1                # true
p hash.value? 2                # true
p hash.value? 30               # false

keyを確認するときは「:」を忘れないように。



Copyright © 2015 AchaPorutePiipo All Rights Reserved.