|变量|是什么?语法是什么意思? [英] What does the |variable| syntax mean?
本文介绍了|变量|是什么?语法是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面的profile
周围的| |
是什么,它是什么意思,为什么在do
之后?我以为do
后面是一个循环块.
What is the | |
around profile
below called, what does it mean, and why it is after do
? I thought do
is followed by a loop block or so.
ticks = get_all[0...MAX].map do |profile|
# ...
end
推荐答案
它就像是foreach,因此profile在每个函数调用中都是不同的值,在get_all中每个元素调用一个函数.
it's like a foreach, so profile will be a different value in each of the functions calls, one function call per element in get_all.
查看此内容:
my_array = [:uno, :dos, :tres]
my_array.each do |item|
puts item
end
这篇关于|变量|是什么?语法是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文