-
-
Save mistyrinth/a2d36282055e837e955e8d1f64b0815e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hash = {"鈴木さん" => 55, "伊藤さん" => 40, "山田さん" => 22, "佐藤さん" => 38} | |
p hash | |
# キーを指定して削除 | |
hash.delete("鈴木さん") | |
p hash | |
# ブロック内の処理がtrueのキーを削除 | |
hash.delete_if{|key, value| | |
value < 30 | |
} | |
p hash | |
# ハッシュを空にする | |
hash.clear | |
p hash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment