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 基礎文法 解いてみた編 1

Posted at

はじめに

Rubyの基礎を学習中の方に向けて記載致します。
実際に問題を解いた内容をOutputします。
省略方法やご参考になる記事等ございましたら、ご教授頂けますと幸いです。

#While文からfor文への変換

qiita.rb
#while文
num = 0
while num < 100 do
  puts num
  num += 1
end


#for文
for num in 0..99 do
  puts num
end

#ハッシュから値だけを取り出し、配列にする。
ただし、hashクラスのvaluesメソッドは利用しないこと。

qiita.rb
# ハッシュ
attr = {name: "田中", age: 27, height: 180, weight: 75}

#回答
values = []
attr.each do |key, value| 
  values << value
end

#さいごに
日々勉強中ですので、随時更新します。
皆様の復習にご活用頂けますと幸いです。

0
0
2

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?