RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: StevenNunez
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
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']
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