From 5acb0c1a604d468af2cd651229866c48ed7c4e24 Mon Sep 17 00:00:00 2001 From: Bruno Volcov Date: Mon, 26 Oct 2015 17:23:27 -0200 Subject: add a cool reference for learn Ruby =) --- ruby.html.markdown | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'ruby.html.markdown') diff --git a/ruby.html.markdown b/ruby.html.markdown index c10255d8..b3ef2a4d 100644 --- a/ruby.html.markdown +++ b/ruby.html.markdown @@ -13,6 +13,7 @@ contributors: - ["Levi Bostian", "https://github.com/levibostian"] - ["Rahil Momin", "https://github.com/iamrahil"] - ["Gabriel Halley", https://github.com/ghalley] + - ["Bruno Volcov", https://github.com/volcov] --- @@ -285,7 +286,7 @@ end #=> iteration 4 #=> iteration 5 -# There are a bunch of other helpful looping functions in Ruby, +# There are a bunch of other helpful looping functions in Ruby, # for example "map", "reduce", "inject", the list goes on. Map, # for instance, takes the array it's looping over, does something # to it as defined in your block, and returns an entirely new array. @@ -576,3 +577,4 @@ Something.new.qux # => 'qux' - [Ruby from other languages](https://www.ruby-lang.org/en/documentation/ruby-from-other-languages/) - [Programming Ruby](http://www.amazon.com/Programming-Ruby-1-9-2-0-Programmers/dp/1937785491/) - An older [free edition](http://ruby-doc.com/docs/ProgrammingRuby/) is available online. - [Ruby Style Guide](https://github.com/bbatsov/ruby-style-guide) - A community-driven Ruby coding style guide. +- [Try Ruby](http://tryruby.org) - Learn the basic of Ruby programming language, interactive in the browser. -- cgit v1.2.3 From 746df3268afcd0307c0da434bf162632be3d53ea Mon Sep 17 00:00:00 2001 From: Bruno Volcov Date: Mon, 4 Jan 2016 17:28:36 -0200 Subject: remove contributors name --- ruby.html.markdown | 1 - 1 file changed, 1 deletion(-) (limited to 'ruby.html.markdown') diff --git a/ruby.html.markdown b/ruby.html.markdown index b3ef2a4d..267889b1 100644 --- a/ruby.html.markdown +++ b/ruby.html.markdown @@ -13,7 +13,6 @@ contributors: - ["Levi Bostian", "https://github.com/levibostian"] - ["Rahil Momin", "https://github.com/iamrahil"] - ["Gabriel Halley", https://github.com/ghalley] - - ["Bruno Volcov", https://github.com/volcov] --- -- cgit v1.2.3 From 82cb669cd77e0b394be0161ea8c688aa78f955d6 Mon Sep 17 00:00:00 2001 From: Ryan Plant Date: Tue, 26 Jan 2016 11:44:47 +1100 Subject: Fix typo --- ruby.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ruby.html.markdown') diff --git a/ruby.html.markdown b/ruby.html.markdown index 3eed2d3c..24dd788a 100644 --- a/ruby.html.markdown +++ b/ruby.html.markdown @@ -285,7 +285,7 @@ hash.each do |key, value| puts "#{key} is #{value}" end -# If you still need and index you can use "each_with_index" and define an index +# If you still need an index you can use "each_with_index" and define an index # variable array.each_with_index do |element, index| puts "#{element} is number #{index} in the array" -- cgit v1.2.3 From 0f5c74a79f328aa1b385a2dae3389d48faa47ce5 Mon Sep 17 00:00:00 2001 From: Ryan Plant Date: Tue, 26 Jan 2016 11:52:06 +1100 Subject: Add note on destructuring assignment --- ruby.html.markdown | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'ruby.html.markdown') diff --git a/ruby.html.markdown b/ruby.html.markdown index 24dd788a..6743de6b 100644 --- a/ruby.html.markdown +++ b/ruby.html.markdown @@ -411,6 +411,15 @@ def guests(*array) array.each { |guest| puts guest } end +# If a method returns an array, you can use destructuring assignment +def foods + ['pancake', 'sandwich', 'quesadilla'] +end +breakfast, lunch, dinner = foods +breakfast # 'pancake' +dinner # 'quesadilla' + + # Define a class with the class keyword class Human -- cgit v1.2.3 From b9c1502cab19360bda496df5a2503a198f7c4f50 Mon Sep 17 00:00:00 2001 From: Ryan Plant Date: Tue, 26 Jan 2016 11:58:46 +1100 Subject: Add note on method naming conventions --- ruby.html.markdown | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'ruby.html.markdown') diff --git a/ruby.html.markdown b/ruby.html.markdown index 6743de6b..bdad4d06 100644 --- a/ruby.html.markdown +++ b/ruby.html.markdown @@ -419,6 +419,19 @@ breakfast, lunch, dinner = foods breakfast # 'pancake' dinner # 'quesadilla' +# By convention, all methods that return booleans end with a question mark +5.even? # false +5.odd? # true + +# And if a method ends with an exclamation mark, it does something destructive +# like mutate the receiver. Many methods have a ! version to make a change, and +# a non-! version to just return a new changed version +company_name = "Dunder Mifflin" +company_name.upcase #=> "DUNDER MIFFLIN" +company_name #=> "Dunder Mifflin" +company_name.upcase! # we're mutating company_name this time! +company_name #=> "DUNDER MIFFLIN" + # Define a class with the class keyword class Human -- cgit v1.2.3 From 236cc1c14c71e561d9ab715079f6974a86fad271 Mon Sep 17 00:00:00 2001 From: Ryan Plant Date: Tue, 26 Jan 2016 11:59:08 +1100 Subject: Fix formatting on comments --- ruby.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ruby.html.markdown') diff --git a/ruby.html.markdown b/ruby.html.markdown index bdad4d06..adf5ce81 100644 --- a/ruby.html.markdown +++ b/ruby.html.markdown @@ -416,8 +416,8 @@ def foods ['pancake', 'sandwich', 'quesadilla'] end breakfast, lunch, dinner = foods -breakfast # 'pancake' -dinner # 'quesadilla' +breakfast #=> 'pancake' +dinner #=> 'quesadilla' # By convention, all methods that return booleans end with a question mark 5.even? # false -- cgit v1.2.3