Forum: Ruby about Array methods

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Cda3d26c2566666a0f507073b1389628?d=identicon&s=25 Kyung won Cheon (kdream95)
on 2009-01-09 03:49
l = [1,2,3,4,5]
head = l[0..2]
p head # => [1,2,3]
p l    # => [1,2,3,4,5]

# I want '[4,5]'

# Is that method in Array?
A61ecce13ed142622f24a5ca3a123922?d=identicon&s=25 Matthew Moss (Guest)
on 2009-01-09 04:00
(Received via mailing list)
On Jan 8, 2009, at 8:49 PM, Kyung won Cheon wrote:

> l = [1,2,3,4,5]
> head = l[0..2]
> p head # => [1,2,3]
> p l    # => [1,2,3,4,5]
>
> # I want '[4,5]'
>
> # Is that method in Array?

l = l[3..-1]
6087a044557d6b59ab52e7dd20f94da8?d=identicon&s=25 Peña, Botp (Guest)
on 2009-01-09 04:16
(Received via mailing list)
From: Matthew Moss [mailto:matt@moss.name]
# > p l    # => [1,2,3,4,5]
# >
# > # I want '[4,5]'
# >
# > # Is that method in Array?
#
# l = l[3..-1]
#

also,

  array.last(2)
51dd8d7754359a0e7363392f6c6eb574?d=identicon&s=25 Mathijs (Guest)
on 2009-01-09 10:10
(Received via mailing list)
Kyung won Cheon schreef:
> l = [1,2,3,4,5]
> head = l[0..2]
> p head # => [1,2,3]
> p l    # => [1,2,3,4,5]
>
> # I want '[4,5]'
>
> # Is that method in Array?

p l-head # => [4,5]
This topic is locked and can not be replied to.