def alphabetize (arr, rev=false)
arr.sort!
if rev
arr.reverse!
return arr
end
numbers=[1,2,3,4,5]
puts alphabetize (numbers)
Assuming that you are on sorting, youâve missed alot of obvious pieces.
You missed Else, and alot.
My code:
def alphabetize(arr, rev=false)
arr.sort!
if rev == true
arr.reverse!
else
arr.sort!
end
end
numbers = [1, 8, 9, 5, 10, 6]
puts alphabetize(numbers)
puts numbers
Edit: End statement is really the thing being missed here.
I donât see the need for running arr.sort! again in the else since it has already been run at the beginning of the method. He also shouldnât need rev==true due to the fact that the if statement will execute based on the already boolean value of ârevâ.
Edit: So to answer the first question it looks like youâre just missing the âendâ for closing the if statement.
I agree with levibarker. I hope Codecademy folks really clean up their act because this sort of this has come up one too many times and it just kills our precious time without adding to our understanding.
âA lotâ is two words. Detail, yo.
Agreed. I had basically the same code that worked just fine, had all the functionality the task called for but was throwing up an error that I couldnât just skip over. There should be a way to skip to the answer. I know some people will abuse it, but the rest of us are just like âwha?â