diff options
author | Gabriel Halley <ghalley@pindropsecurity.com> | 2015-10-07 15:26:10 -0400 |
---|---|---|
committer | Gabriel Halley <ghalley@pindropsecurity.com> | 2015-10-07 15:26:10 -0400 |
commit | f4c13bc6963a79bf419f78a554c5abf3bd7a5bd8 (patch) | |
tree | fafa8e6adc5ebd7b95727569820e08c63fa4fdee /ruby.html.markdown | |
parent | e3c528bb81a09d715cada5f2d7dac04853ac0ccc (diff) |
array first and last methods
Diffstat (limited to 'ruby.html.markdown')
-rw-r--r-- | ruby.html.markdown | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/ruby.html.markdown b/ruby.html.markdown index ec7b2f5e..7fe34336 100644 --- a/ruby.html.markdown +++ b/ruby.html.markdown @@ -155,6 +155,7 @@ array = [1, 2, 3, 4, 5] #=> [1, 2, 3, 4, 5] # Arrays can be indexed # From the front array[0] #=> 1 +array.first #=> 1 array[12] #=> nil # Like arithmetic, [var] access @@ -165,6 +166,7 @@ array.[] 12 #=> nil # From the end array[-1] #=> 5 +array.last #=> 5 # With a start index and length array[2, 3] #=> [3, 4, 5] |