Help – I’m going nuts trying to figure out what’s wrong with my code for this section:
def alphabetize(arr,rev=false) arr.sort! if rev==false arr.sort! else arr.reverse! end puts arr end
It works perfectly in the command window - it will sort an array and reverse it if rev is included as a parameter - but I consistently get the message “It looks like your method doesn’t default to alphabetizing an array when it doesn’t receive a second parameter”. Anyone know why this is? I also tried this simpler permutation:
def alphabetize(arr,rev=false) arr.sort! if rev==true arr.reverse! end puts arr end
It works just as effectively, but I still get an error message.