Logo
Explore Help
Sign In
mirrors/brew
1
0
Fork 0
You've already forked brew
mirror of https://github.com/Homebrew/brew.git synced 2025-07-14 16:09:03 +08:00
Code Issues Packages Projects Releases Wiki Activity
brew/Library/Homebrew/extend/symbol.rb

6 lines
120 B
Ruby
Raw Normal View History

Define Symbol#to_proc for Ruby 1.8.6 Ruby 1.8.6 doesn't have Symbol#to_proc, which allows things like map(&:to_s) rather than map { |o| o.to_s }. 1.8.7 does, though, and since it is used in a bunch of the superenv code we should attempt to keep it compatible with 1.8.6. Closes Homebrew/homebrew#16046.
2013-01-09 17:36:17 -06:00
class Symbol
def to_proc
Symbol#to_proc: fix with arrays of arrays Previously, with nested arrays, the Symbol#to_proc would iterate over the first item in the nested array instead of the array itself, e.g.: [[1,2], [3,4]].map(&:first) #=> NoMethodError: undefined method `first' for 1:Fixnum
2014-03-08 10:37:58 -08:00
proc { |*args| args.shift.send(self, *args) }
Define Symbol#to_proc for Ruby 1.8.6 Ruby 1.8.6 doesn't have Symbol#to_proc, which allows things like map(&:to_s) rather than map { |o| o.to_s }. 1.8.7 does, though, and since it is used in a bunch of the superenv code we should attempt to keep it compatible with 1.8.6. Closes Homebrew/homebrew#16046.
2013-01-09 17:36:17 -06:00
end unless method_defined?(:to_proc)
end
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.23.8 Page: 129ms Template: 2ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API