【发布时间】:2012-03-14 20:21:25
【问题描述】:
我遇到了一个代码 sn-p,它有以下内容
a.each_slice(2).map(&:reverse)
我不知道&: 运算符的功能。这是如何运作的?
【问题讨论】:
-
…What is this
&:lastRuby Construct Called?,What do you call the&:operator in Ruby?,What doesmap(&:name)do in this Ruby code?,What are:+and&+in ruby?,&:views_countinPost.published.collect(&:views_count),Ruby Proc Syntax,How does “(1..4).inject(&:+)” work in Ruby,… -
…What does following statement
&:property?、What does the&mean in the following ruby syntax?、Why would one use the unary operator on a property in ruby? i.e&:first、how doesArray#maphave parameter to do something like this? 和 what does&:mean in ruby, is it a block mixed with a symbol?。
标签: ruby