diff options
author | Adam Bard <github@adambard.com> | 2013-08-13 19:55:28 -0700 |
---|---|---|
committer | Adam Bard <github@adambard.com> | 2013-08-13 19:55:28 -0700 |
commit | f733ea36d2da7748b21a7ec356bdf147541b3b2b (patch) | |
tree | fced011bc515b9052f2d3817529a231a414acd41 | |
parent | 4bd33d0d72b4117095f3d7a2c9afacb4bb6bd984 (diff) | |
parent | 9fd70ffbb12e92a4bd129cfbe28d91e07138c398 (diff) |
Merge pull request #209 from NickLaMuro/ruby-fixes
Ruby tweaks
-rw-r--r-- | ruby.html.markdown | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/ruby.html.markdown b/ruby.html.markdown index 68c5b524..19f2ec86 100644 --- a/ruby.html.markdown +++ b/ruby.html.markdown @@ -6,6 +6,7 @@ contributors: - ["Joel Walden", "http://joelwalden.net"] - ["Luke Holder", "http://twitter.com/lukeholder"] - ["Tristan Hume", "http://thume.ca/"] + - ["Nick LaMuro", "https://github.com/NickLaMuro"] --- ```ruby @@ -117,11 +118,11 @@ status == :approved #=> false # Arrays # 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 -array = [1, "hello", false] #=> => [1, "hello", false] +[1, "hello", false] #=> [1, "hello", false] # Arrays can be indexed # From the front @@ -173,9 +174,9 @@ new_hash.keys #=> [:defcon, :action] if true "if statement" elsif false - "else if, optional" + "else if, optional" else - "else, also optional" + "else, also optional" end for counter in 1..5 @@ -190,7 +191,8 @@ end # HOWEVER, No-one uses for loops. # 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". -# 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 block is passed a counter as a parameter. |