About Array methods


#1

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?


#2

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]


#3

From: Matthew M. [mailto:removed_email_address@domain.invalid]

> p l # => [1,2,3,4,5]

>

> # I want ‘[4,5]’

>

> # Is that method in Array?

l = l[3…-1]

also,

array.last(2)


#4

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]