나는 누군가의 루비 코드를 검토하고있어 그 안에 그들은 비슷한 작성했습니다 :& : aFunction의 &는 무엇을하고 있습니까?
class Example
attr_reader :val
def initialize(val)
@val = val
end
end
def trigger
puts self.val
end
anArray = [Example.new(10), Example.new(21)]
anArray.each(&:trigger)
:trigger
는 심볼이 촬영 수단과 &
가 proc
로 변환을?
그렇다면 self.
을 사용하는 것 외에 변수를 트리거로 전달하는 방법이 있습니까?
이 관련 그러나 대답하지 않습니다 : http://www.ruby-forum.com/topic/198284#863450
관련 질문 : HTTP : // 유래합니다. com/questions/1217088/what-does-mapname-mean-in-ruby –
감사합니다. @AndrewGrimm. – AJP
관련 항목 : http://stackoverflow.com/questions/23695653/can-you-supply-arguments-to-the-mapmethod-syntax-in-ruby –