diff options
author | Claudio Secco <claudiosecco@hotmail.com> | 2020-05-02 16:09:41 -0300 |
---|---|---|
committer | Claudio Secco <claudiosecco@hotmail.com> | 2020-05-02 16:09:41 -0300 |
commit | d9ee9ce3903f078c68d796464c70c463c1bf133b (patch) | |
tree | 3bc04d07bcc9ec4142c7642a03f91e7f199988b3 /ruby.html.markdown | |
parent | a67f4663eb1b477cb50da9986fc5da945864ebab (diff) |
[ruby/en] add .map($:method) sintax in blocks context
Diffstat (limited to 'ruby.html.markdown')
-rw-r--r-- | ruby.html.markdown | 5 |
1 files changed, 5 insertions, 0 deletions
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' |