0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[Ruby]ハッシュ_値の再代入

Posted at

ハッシュの値の変更について

作成したハッシュにキーを指定することによって、値を再代入することができます

使い方

ハッシュオブジェクト[キー] = オブジェクト

例えば・・・

hash = {"Mike" => 26, "John" => 50}
hash["Mike"] = 27

上記によって、特定のキー"Mike"の値を26から27に再代入することができました。

特定のキーの値を取得するには・・・

hash.values[0]
# 27

添字を指定することによって取得できます

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?