Skip to content

Instantly share code, notes, and snippets.

@mistyrinth
Created December 1, 2018 04:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mistyrinth/a2d36282055e837e955e8d1f64b0815e to your computer and use it in GitHub Desktop.
Save mistyrinth/a2d36282055e837e955e8d1f64b0815e to your computer and use it in GitHub Desktop.
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