0

I was reading about collect method here http://apidock.com/ruby/Array/collect and I find this example:

>> ['a', 'b', 'c'].collect(&:capitalize)
=> ["A", "B", "C"]

Where it is short and nice way of:

>> ['a', 'b', 'c'].collect{|letter| letter.capitalize}
=> ["A", "B", "C"]

What does &: means in the first line???

egyamado
  • 1,111
  • 4
  • 23
  • 44
  • 4
    here's another one http://stackoverflow.com/questions/1961030/ruby-ruby-on-rails-ampersand-colon-shortcut – jvnill May 28 '13 at 07:53
  • @jvnill Thanks for your second link, it aswers my questiona bout :&. Do you know well written Ruby documentation?I found Ruby-doc and ApiDoc are the same and not clear most of the time – egyamado May 28 '13 at 08:05
  • 1
    @egyamado I would recommend this book: http://books.google.co.uk/books/about/Agile_Web_Development_With_Rails.html?id=pQORSQAACAAJ&redir_esc=y and there is plenty of documentation help at the info page for this tag: http://stackoverflow.com/tags/ruby-on-rails/info – Matt May 28 '13 at 08:11
  • I don't know why the question deserve to be voted down. Its unfair. – egyamado May 28 '13 at 08:17
  • 1
    If you hover over the downvote link, the tooltip shows a couple of possible reasons for downvoting, one of which is "This question does not show any research effort". And it doesn't. There is no indication in the question what you have already tried to find the answer. You have not said why you aren't satisfied with the answers to the other 22 times this exact same question has been asked and answered on StackOverflow. Note: *I* didn't downvote, but I can certainly understand how someone might consider that poor research effort. – Jörg W Mittag May 28 '13 at 09:09

0 Answers0