What is wrong with this code?


def alphabetize (arr, rev=false)
if rev
return arr
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)
        if rev == true
    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?"