1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Add Symbol#to_proc, which allows for, e.g. [:foo, :bar].map(&:to_s).

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3118 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Marcel Molina 2005-11-21 02:15:32 +00:00
parent e9b26c52a2
commit 69bf71f5e9
3 changed files with 15 additions and 0 deletions

View file

@ -1,5 +1,7 @@
*SVN*
* Add Symbol#to_proc, which allows for, e.g. [:foo, :bar].map(&:to_s). [Marcel Molina Jr.]
* Add Array#to_strings which to_s's all elements in an array. [Marcel Molina Jr., Sam Stephenson]
* Added the following methods [Marcel Molina Jr., Sam Stephenson]:

View file

@ -0,0 +1,5 @@
class Symbol #:nodoc:
def to_proc
Proc.new { |obj, *args| obj.send(self, *args) }
end
end

View file

@ -0,0 +1,8 @@
require 'test/unit'
require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/symbol'
class TestSymbol < Test::Case::TestUnit
def test_to_proc
assert_equal %w(one two three), [:one, :two, :three].map &:to_s
end
end