190 results found for ruby &:
ruby on rails block sytax using &: ruby on rails block sytax using &: So say I have a Question model and an Answer model and Question has_many
Assume that Game is an active record model, what does the & mean in the following code? Games.group_by(&:genre) Tags: ruby-on-rails ruby See this: What do
What do you call the &: operator in Ruby? What do you call the &: operator in Ruby? Possible Duplicates: Ruby/Ruby on Rails ampersand colon shortcut
What is this &:last Ruby construct called? What is this &:last Ruby construct called? What are things like survey.map(&:questions).flatten.compact
using &: . Tags: ruby Symbol#to_proc takes the first argument to be the receiver and passes on any extra arguments it receives to the method, but in this
results.concat(Question.find_all_by_survey_section_id(section.id)) end results end I feel like I could use the &: ( Symbol#to_proc ) and returning methods in there somehow. Tags: ruby-on-rails ruby arrays Assuming
missing around the array Thanks and good morning! Alex Tags: ruby-on-rails ruby arrays The entire conversion you are making is unnecessary. You can pass the
That's the &: in the select(&:odd?) and the inject(&:+) above. Tags: c# ruby lambda extension-methods The following is direct, literal (as much as
inside Rails, is to use the Symbol#to_block method like JRL mentioned: p test_method &:upcase So just add the &: before the method name. As ennuikiller
Tags: ruby-on-rails ruby group-by grouping Assuming recorded_on is a date, and not a DateTime: @records = Record.all.group_by(&:recorded_on) If it is a