What does the |variable| syntax mean? [duplicate]
问题 This question already has answers here : What are those pipe symbols for in Ruby? (7 answers) Closed 8 days ago . 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 回答1: 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. see this: my_array = [:uno, :dos, :tres] my_array.each do