From f4c13bc6963a79bf419f78a554c5abf3bd7a5bd8 Mon Sep 17 00:00:00 2001 From: Gabriel Halley Date: Wed, 7 Oct 2015 15:26:10 -0400 Subject: array first and last methods --- ruby.html.markdown | 2 ++ 1 file changed, 2 insertions(+) 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] -- cgit v1.2.3