Duff O'Melia

Ruby Quicktips

I’ve been enjoying the Ruby Quicktips blog. Even if you’ve been using Ruby for years, I’m betting there’s still things there you’ll find useful.

For example, did you know you can pass a number parameter to Array#first and Array#last?

1
2
3
4
5
6
7
x = [1,2,3,4,5,6,7,8,9,10]

x.first 5
=> [1,2,3,4,5]

x.last 2
=> [9,10]