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 3 years have passed since last update.

ハッシュについて(Ruby)

Last updated at Posted at 2020-04-13

##ハッシュのイメージ

{キー1: 値1, キー2: 値2, キー3: 値3}
member = {name: "Ryohei", age: 24}

##ハッシュの要素を取り出す

member[:name]
=> Ryohei

##ハッシュの追加方法

member[:place] = "Okayama"
=> {name: "Ryohei", age: 24, place: Okayama}

##配列の中にハッシュがあり、取り出す場合

blog = [{title: "今日は暑いな", content: "でも頑張るぞ"},{title: "今日の仕事が終われば", content: "明日から旅行だ"},{title: "明日から", content: "プログラミングするぞ"}]
puts blog[0][:title]
=>明日から
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?