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

ハッシュは使い分け必要なのか?

Posted at

ハッシュの使い分けに関して

post = {}

post[:name]
post[:name]  = gets.chomp  
post[:price]  = gets.to_i
post[:count] = gets.to_i
name = gets.chomp
price = gets.to_i
count = gets.to_i

post = {name: name,price: price,count: count}

結論どちらも一緒みたいです

一緒なら文字数が少なく、先にハッシュだとわかる1つ目がおすすめだと思います!

1
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
1
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?