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.

【Ruby】times, uptoの小さなメモ

Posted at
###########
# times
10.times{|i|
  p "times: #{i}"
}

10.times{
  p "times"
}


10.times do |i|
  p "times: #{i}"
end

10.times do
  p "times"
end


#########
# upto

10.upto(15){
  p "upto"
}

10.upto(15){ |i|
  p "upto: #{i}"
}


10.upto(15) do
  p "upto"
end


10.upto(15) do |i|
  p "upto: #{i}"
end
結果
"times: 0"
"times: 1"
"times: 2"
"times: 3"
"times: 4"
"times: 5"
"times: 6"
"times: 7"
"times: 8"
"times: 9"
"times"
"times"
"times"
"times"
"times"
"times"
"times"
"times"
"times"
"times"
"times: 0"
"times: 1"
"times: 2"
"times: 3"
"times: 4"
"times: 5"
"times: 6"
"times: 7"
"times: 8"
"times: 9"
"times"
"times"
"times"
"times"
"times"
"times"
"times"
"times"
"times"
"times"
"upto"
"upto"
"upto"
"upto"
"upto"
"upto"
"upto: 10"
"upto: 11"
"upto: 12"
"upto: 13"
"upto: 14"
"upto: 15"
"upto"
"upto"
"upto"
"upto"
"upto"
"upto"
"upto: 10"
"upto: 11"
"upto: 12"
"upto: 13"
"upto: 14"
"upto: 15"

Process finished with exit code 0
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?