Ruby基礎編 備忘録その8
ハッシュ
- 配列と同様に複数のデータを扱うことができる。
- 配列は違いハッシュは「キー」「値」をもつ
words ={ "apple" => "りんご", "book" => "本", "fish" => "魚" } puts words["apple"] #結果 りんご words["tea"] = "お茶" #ハッシュの最後に追加
words ={ "apple" => "りんご", "book" => "本", "fish" => "魚" } puts words["apple"] #結果 りんご words["tea"] = "お茶" #ハッシュの最後に追加