Instantly share code, notes, and snippets.

@kdnk /to_proc.md
Last active Apr 16, 2018

Embed
What would you like to do?
class Symbol
  def to_proc
    Proc.new do |obj, *args|
      obj.send self, *args
    end
  end
end

ex)

:reverse.to_proc #=> Proc.new { |i| i.reverse }

気持ちとしてはこんな感じ。 (文法的には間違ってる)

@tag_names.map{&:name}
@tag_names.map{&:name.to_proc}
@tag_names.map{&proc { |tag| tag.name }}
@tag_name.map{ |tag| tag.name }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment