王筝的博客
ruby学习

 

 

http://api.rubyonrails.org/classes/Array.html#method-i-second

 

[27] pry(main)> list = ["a", "b", "c", "d"]
=> ["a", "b", "c", "d"]
[28] pry(main)> list.first
=> "a"
[29] pry(main)> list.second
=> "b"
[30] pry(main)> list.third
=> "c"
[32] pry(main)> list.second_to_last
=> "c"q

 

Leave a Reply