8 kyu
Array#second
2,277 of 2,289Lordnibbler
Description:
Define a new instance method on the Array
class called second
, which returns the second item in an array (similar to the way .first
and .last
work in Ruby).
If there is no element with index 1
in the array, return nil
.
Examples
[3, 4, 5].second # => 4
[].second # => nil
Fundamentals
Arrays
Similar Kata:
Stats:
Created | May 9, 2014 |
Published | May 24, 2014 |
Warriors Trained | 3576 |
Total Skips | 166 |
Total Code Submissions | 9231 |
Total Times Completed | 2289 |
Ruby Completions | 2277 |
Total Stars | 29 |
% of votes with a positive feedback rating | 92% of 182 |
Total "Very Satisfied" Votes | 157 |
Total "Somewhat Satisfied" Votes | 20 |
Total "Not Satisfied" Votes | 5 |