Skip to content

Instantly share code, notes, and snippets.

@mistyrinth
Created November 20, 2018 08:56
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/7d1295e86261208e85e3de4c37d5ffda to your computer and use it in GitHub Desktop.
Save mistyrinth/7d1295e86261208e85e3de4c37d5ffda to your computer and use it in GitHub Desktop.
hash = {"ワンピース" => 2000, "スカート" => 1000, "ブラウス" => 1500}
# デフォルトの設定
hash.default = "none"
print("ワンピースの価格は ", hash["ワンピース"], " 円です。\n")
print("スカートの価格は ", hash["スカート"], " 円です。\n")
print("ブラウスの価格は ", hash["ブラウス"], " 円です。\n")
print("カーディガンの価格は ", hash["カーディガン"], " 円です。\n")
# 値の変更
hash["スカート"] = 850
# キーの追加
hash["カーディガン"] = 1200
print("価格が変わりました!\n")
print("スカートの価格は ", hash["スカート"], " 円です。\n")
print("カーディガンの価格は ", hash["カーディガン"], " 円です。\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment