Feature #4146: Improvement of Symbol and Proc
http://redmine.ruby-lang.org/issues/show/4146

=E8=B5=B7=E7=A5=A8=E8=80=85: Nobuyoshi Nakada
=E3=82=B9=E3=83=86=E3=83=BC=E3=82=BF=E3=82=B9: Open, =E5=84=AA=E5=85=88=E5=
=BA=A6: Normal
=E3=82=AB=E3=83=86=E3=82=B4=E3=83=AA: core

=E7=8F=BE=E5=9C=A8Symbol#to_proc=E3=81=A7 %w[12 45 32].map(&:to_i) =E3=81=
=AE=E3=82=88=E3=81=86=E3=81=AA=E3=81=93=E3=81=A8=E3=81=AF=E3=81=A7=E3=81=8D=
=E3=81=BE=E3=81=99=E3=81=8C=E3=80=81
=E5=BC=95=E6=95=B0=E3=82=92=E4=BB=98=E3=81=91=E3=81=A6=E3=83=A1=E3=82=BD=E3=
=83=83=E3=83=89=E3=82=92=E5=91=BC=E3=81=B6=E3=81=93=E3=81=A8=E3=81=AF=E3=81=
=A7=E3=81=8D=E3=81=BE=E3=81=9B=E3=82=93=E3=80=82Symbol=E3=83=AA=E3=83=86=E3=
=83=A9=E3=83=AB=E3=81=AB=E5=BC=95=E6=95=B0=E3=82=92=E4=BB=98=E3=81=91
=E3=81=9F=E3=82=89=E3=81=9D=E3=81=AE=E5=BC=95=E6=95=B0=E3=81=A8=E5=85=B1=E3=
=81=AB=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E3=82=92=E5=91=BC=E3=81=B6Proc=
=E3=82=92=E4=BD=9C=E3=82=8B=E6=A7=8B=E6=96=87=E3=81=A8=E3=81=84=E3=81=86=E3=
=81=AE=E3=81=AF=E3=81=A9=E3=81=86=E3=81=A7=E3=81=97=E3=82=87=E3=81=86=E3=81=
=8B=E3=80=82

  %w[12 45 32].map(&:to_i(9)).map(&:*(2)) #=3D> [22, 82, 58]
  %w[abc def ghi].map(&:[1])              #=3D> ["b", "e", "h"]


----------------------------------------
http://redmine.ruby-lang.org
ZGlmZiAtLWdpdCBpL3BhcnNlLnkgdy9wYXJzZS55Cmlu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