From d9ee9ce3903f078c68d796464c70c463c1bf133b Mon Sep 17 00:00:00 2001 From: Claudio Secco Date: Sat, 2 May 2020 16:09:41 -0300 Subject: [ruby/en] add .map($:method) sintax in blocks context --- ruby.html.markdown | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'ruby.html.markdown') diff --git a/ruby.html.markdown b/ruby.html.markdown index 97f7a516..3111d09b 100644 --- a/ruby.html.markdown +++ b/ruby.html.markdown @@ -327,6 +327,11 @@ puts doubled puts array #=> [1,2,3,4,5] +# another useful sintax is .map(&:method) +a = ["FOO", "BAR", "BAZ"] +a.map { |s| s.downcase } #=> ["foo", "bar", "baz"] +a.map(&:downcase) #=> ["foo", "bar", "baz"] + # Case construct grade = 'B' -- cgit v1.2.3