【发布时间】:2012-11-03 04:48:05
【问题描述】:
可能重复:
What does map(&:name) mean in Ruby?
What do you call the &: operator in Ruby?
只是看一些 railscast 并看到这样的代码:
[Category, Product, Person].each(&:delete_all)
我知道它会擦除这些模型的所有记录,但我不知道这个 &:delete_all 是什么意思。
【问题讨论】:
-
…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,… -
……Ruby map method syntax question,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