I'm doing some Ruby excercises. My goal is to create a method which reproduces the first and last number of an array.
My way of thinking was:
#create array
a = [1,2,3,4]
#create method
def lastFirst
return a[0,3]
end
#call the method with an array
lastFirst(a)
But this produces [1,2,3] instead of what I want, which is (1,3).
Any thoughts on what I'm doing wrong?