From a67f4663eb1b477cb50da9986fc5da945864ebab Mon Sep 17 00:00:00 2001 From: Claudio Secco Date: Sat, 2 May 2020 13:03:36 -0300 Subject: include %w option --- ruby.html.markdown | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ruby.html.markdown b/ruby.html.markdown index 376f4a47..97f7a516 100644 --- a/ruby.html.markdown +++ b/ruby.html.markdown @@ -181,6 +181,9 @@ array = [1, 2, 3, 4, 5] #=> [1, 2, 3, 4, 5] # Arrays can contain different types of items. [1, 'hello', false] #=> [1, "hello", false] +# You might prefer %w instead of quotes +%w[foo bar baz] #=> ["foo", "bar", "baz"] + # Arrays can be indexed. # From the front... array[0] #=> 1 -- cgit v1.2.3 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(+) 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 From 20a468579ac87bd56f1f9e95a7f065e3519522af Mon Sep 17 00:00:00 2001 From: Claudio Secco <41170119+claudiosecco@users.noreply.github.com> Date: Tue, 7 Jul 2020 20:27:34 -0300 Subject: [ruby/en] fix typo --- ruby.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruby.html.markdown b/ruby.html.markdown index 3111d09b..0e35a7ec 100644 --- a/ruby.html.markdown +++ b/ruby.html.markdown @@ -327,7 +327,7 @@ puts doubled puts array #=> [1,2,3,4,5] -# another useful sintax is .map(&:method) +# another useful syntax is .map(&:method) a = ["FOO", "BAR", "BAZ"] a.map { |s| s.downcase } #=> ["foo", "bar", "baz"] a.map(&:downcase) #=> ["foo", "bar", "baz"] -- cgit v1.2.3