1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-08-07 07:16:42 +02:00

Merge pull request #209 from NickLaMuro/ruby-fixes

Ruby tweaks
This commit is contained in:
Adam Bard
2013-08-13 19:55:28 -07:00

View File

@@ -6,6 +6,7 @@ contributors:
- ["Joel Walden", "http://joelwalden.net"] - ["Joel Walden", "http://joelwalden.net"]
- ["Luke Holder", "http://twitter.com/lukeholder"] - ["Luke Holder", "http://twitter.com/lukeholder"]
- ["Tristan Hume", "http://thume.ca/"] - ["Tristan Hume", "http://thume.ca/"]
- ["Nick LaMuro", "https://github.com/NickLaMuro"]
--- ---
```ruby ```ruby
@@ -117,11 +118,11 @@ status == :approved #=> false
# Arrays # Arrays
# This is an array # This is an array
[1, 2, 3, 4, 5] #=> [1, 2, 3, 4, 5] array = [1, 2, 3, 4, 5] #=> [1, 2, 3, 4, 5]
# Arrays can contain different types of items # Arrays can contain different types of items
array = [1, "hello", false] #=> => [1, "hello", false] [1, "hello", false] #=> [1, "hello", false]
# Arrays can be indexed # Arrays can be indexed
# From the front # From the front
@@ -190,7 +191,8 @@ end
# HOWEVER, No-one uses for loops. # HOWEVER, No-one uses for loops.
# Instead you should use the "each" method and pass it a block. # Instead you should use the "each" method and pass it a block.
# A block is a bunch of code that you can pass to a method like "each". # A block is a bunch of code that you can pass to a method like "each".
# It is analogous to lambdas, anonymous functions or closures in other programming languages. # It is analogous to lambdas, anonymous functions or closures in other
# programming languages.
# #
# The "each" method of a range runs the block once for each element of the range. # The "each" method of a range runs the block once for each element of the range.
# The block is passed a counter as a parameter. # The block is passed a counter as a parameter.