RailsCasts Pro episodes are now free!

Learn more or hide this

Steven Nunez's Profile

GitHub User: StevenNunez

Comments by Steven Nunez

Avatar

This is using symbol to proc. &:save is converted to {|obj| obj.save}. That means that any message you can send to an object is sendable. Really cool stuff! Use it in things like

ruby
class User
  attr_accessor :name, :email
  def initialize(name, email)
    @name, @email = name, email
  end
end

bobby = User.new("bobby", 'bboy@example.com')
annie = User.new("annie", 'aack@example.com')
[bobby, annie].map(&:email) #=> ['bboy@example.com', 'aack@example.com']