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?

n.times.xxx の構文

Posted at

n.times.map

例:0から4までの数を2倍した配列を作る

result = 5.times.map{ |i| i * 2 }
p result 
# [0, 2, 4, 6, 8]

n.times.sum

例:0から9までの合計を求める

sum = 10.times.sum{|i| i}
puts sum 
 #  45
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?